Raspberry Pi Wifi Controlled Video Streaming Robot

40,396

322

27

Introduction: Raspberry Pi Wifi Controlled Video Streaming Robot

About: I love Arduino and Raspberry pi and High Voltage... i build robots and also other cool stuff so stay tuned !!

Ever thought about building a cool robot with a camera on it ? Well, you came to the right place, I will show you step by step about how to build this robot.

With this you can go ghost hunting at night by controlling and seeing the video feed on your computer or drive it outside and just explore while sitting inside, it is very fun to drive.

Step 1: Materials Required

1. Raspberry Pi

2. USB WiFi Adapter (If you are using raspberry pi 2)

3. USB Webcam

4. SD Card with Raspbian installed

5. Power Bank

6. Robot Chassis with Motors (I used 300 rpm motors)

7. L293D IC or L298 Motor Driver

8. 9v Battery or a Battery Pack (If you are using a 9v battery then I would recommend to connect 2 in parallel)

9. A Switch

10. Breadboard or PCB if you prefer to solder

11. M/M and and M/F Jumper wires

Tools

1. Soldering Iron

2. Screwdriver

3. Double Sided Tape

Step 2: Assembling the Chassis

Solder wires onto the motors and mount the motors on the chassis. If you don't have a soldering iron then you can twist the wires and attach them with electrical tape but it is not recommended as it will be quite a weak joint.

Step 3: Preparing the Raspberry Pi

1. Install Raspbian on a SD Card and boot raspberry pi with a monitor, keyboard, mouse, wifi adapter and webcam connected.

2. From the raspi-config menu enable ssh

3. Go into the desktop and connect to your wifi network from the wifi option on the top right corner

4. Once connected check your Pi's ip address by typing ifconfig in the terminal

5. Open IDLE 2 from the programming tab from the taskbar and copy the code pi_robot and save it

6. To install the webcam I want you to watch this video made by Anand Nayyar

7. The other things I did was to change the resolution to 720p instead of 480p and search for "stream_maxrate" and change it to 3. To achieve a higher fps in streaming I also overclocked the Pi to 1ghz

TROUBLESHOOTING

When I tried to run the code in terminal with the command "cd Videos"(Because that's where I saved it) then "python pi_robot.py" it said syntax error so what I did was open the code in terminal with the command "sudo nano pi_robot.py" and erased the lines that already written in python and are not a part of the code and after that it worked. I don't know what was wrong so if anyone knows I would be happy to hear an explanation about this in the comments.

Step 4: Circuit

The circuit is pretty simple and it gets even simpler if you use a L298 motor driver board. If you are using a L298 motor driver board then you just have to wire the gpio pins like in the second schematic.

Step 5: Mounting Everything on the Chassis

Well the pictures tell pretty much everything about how I have assembled it but of course yours will be different if you use a different chassis. I used double sided foam tape to mount everything on the chassis and try to use shorter wires so , it looks better.

Step 6: How to Operate It

To start controlling your robot follow the following steps -

1. Switch on the Raspberry Pi but do not flip on the switch that connects the battery pack to the L293D yet

2. Connect to it through ssh using the program putty if you are on windows

3. Type in the command "sudo motion" and then open your internet browser and type in your Pi's IP address with 8081 at the end like "192.168.45.64:8081" and you should get the video feed. If it doesn't work then type 8080 instead of 8081

4. Now go back to the terminal and locate where you had saved your pi_robot.py file. I had saved it in the Videos folder, so the command is,"cd Videos" then "python pi_robot.py". Remember, everything is case sensitive

5. After that the program will start running. Now flip on the switch, now you should be able to control the robot from the arrow keys of your keyboard

6. Press the forward arrow and check if both the motors are moving in the right direction. If one of the motors is moving in the wrong direction then switch the two motor connections that connect to the L293D

Step 7: Controlling From a Phone

All the steps are the same, you just have download the app "JuiceSSH" from the play store. To control the robot you need arrow keys but a normal smartphone keyboard doesn't have arrow keys so we need to download an app Hacker's Keyboard'. Then connect to it like you did in windows.

Step 8: Some Pictures and Videos

The webcam video quality is descent but the fps is only 2 or 3. The video quality is good when outside but not when inside. It can drive on offroad terrain but not very well, it could if you use a higher voltage to drive the motors like with a small 12v battery.

Wireless Contest

Runner Up in the
Wireless Contest

Make It Move Contest 2017

Third Prize in the
Make It Move Contest 2017

Raspberry Pi Contest 2017

Participated in the
Raspberry Pi Contest 2017

2 People Made This Project!

Recommendations

  • Make it Glow Contest

    Make it Glow Contest
  • First Time Author Contest

    First Time Author Contest
  • PCB Challenge

    PCB Challenge

27 Discussions

0
JonnyBoy2010
JonnyBoy2010

Question 3 months ago

Hi, the tutorial has been great, but I do have a question. When I run the code I get this error message

"Traceback (most recent call last):
File "my_pi_robot.py", line 21, in <module>
char = screen.getch()"

Has anyone else run into this problem?

0
Tusharpatil
Tusharpatil

Question 2 years ago on Step 3

Traceback (most recent call last):
File "/home/pi/pi_robot.py", line 3, in
from curses import curses
ImportError: cannot import name 'curses'
why this error coming while running the program

0
ajithreddy
ajithreddy

Answer 4 months ago

python module is missing
Do
$ pip install curse
if pip is not there install the pip using python

0
Arduino Tech
Arduino Tech

Answer 2 years ago

I don't know what is causing this error how to solve it either but I think do these to fix it maybe -
1. Use the latest version of raspbian
2. Use IDLE 2 instead of 3
3. Place the program in some other folder and not in the pi folder nor on desktop

If these don't work then ask again I will be there to help

0
Sporkpork2006
Sporkpork2006

10 months ago

Can you use a night vision camera

0
Dakshghjkl
Dakshghjkl

Question 2 years ago

Can it be used worlwide?

0
Arduino Tech
Arduino Tech

Reply 2 years ago

No, it has to be on the same wifi network

0
calebs08
calebs08

Reply 1 year ago

You can port forward

0
calebs08
calebs08

1 year ago

Are you sure the wiring diagram is correct?

It seems different
to the images of the built product, and when I wire up my Pi v3B in the
same way (GPIO pins are the same as v2B in the diagram), the Pi won't
even boot.

thanks! Caleb (11 yrs)

0
VenomousAgent_X
VenomousAgent_X

Question 1 year ago on Step 3

i took up this project and i'm interested to work on it...
where to download motion software

0
guptaji97
guptaji97

Question 1 year ago

Hi there,
I am working on a similar project. I just wanted to know how to the video recorded by pi-cam to remotely located server.
I am very new to raspberry, and cant understand the code written properly.
Please help
Thankyou

0
maheshs80
maheshs80

Question 2 years ago on Step 7

How to control robot while opening web page on Android or iOS
Is there any button in web site

0
IllIN
IllIN

3 years ago

Awesome project I have to make one,

Could someone please suggest some good motors for this project?
Why did you (Creator) use 300 rpm motor?
The motors i can find online for sale with 300 Rpm is pretty expensive like 320 dollars each. and only 24 volt dc.
So i thinking there are some cheaper motors available? I can find some pretty cheap ones with 14500 Rpm with a torque of 46,2 gcm i wonder if that would do the trick?
If someone could help me out i would be grateful, since i´m rather inexperienced.


Once again awesome project, thanks for sharing

0
Arduino Tech
Arduino Tech

Reply 3 years ago

Here are a couple of links - Small Motor and a motor of the size I used OR you could buy a complete robot chassis. Just search 'robot chassis' and you will also get many other options. Good luck and if you liked my instructable then vote for me in the Raspberry Pi contest :)

0
IllIN
IllIN

Reply 3 years ago

Thanks for the help, you got a vote from me.

For some reason the hyperlinks doesn´t work? could you copy them as url is?

0
Arduino Tech
Arduino Tech

Reply 2 years ago

https://www.ebay.com/itm/Arduino-Smart-Car-Robot-Plastic-Tire-Wheel-with-DC-3-6v-Gear-Motor-for-Robot-IU/273020303457?hash=item3f91473861:g:OEoAAOSw59VZ4IW4 , https://www.ebay.com/itm/4WD-Smart-Robot-Car-Chassis-Kits-W-Magneto-Speed-Encoder-For-Arduino-51-Replace/162809513764?hash=item25e8340724:g:BxAAAOSwLdBaJoFf

0
IllIN
IllIN

Reply 2 years ago

Thanks a lot, much appreciated

0
Arduino Tech
Arduino Tech

Reply 3 years ago

it runs for maybe 2 hours maybe

0
IgorF2
IgorF2

Reply 3 years ago

Thanks for the information! :)