Raspberry Pi Wifi Controlled Video Streaming Robot

by Arduino Tech in Circuits > Raspberry Pi

46858 Views, 342 Favorites, 0 Comments

Raspberry Pi Wifi Controlled Video Streaming Robot

cover.jpg

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.

Materials Required

IMG_20171112_162815.jpg

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

Assembling the Chassis

IMG_20171113_192657.jpg

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.

Preparing the Raspberry Pi

Raspberry Pi as Webcam Server
code.JPG
code3.JPG
code2.JPG

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.

Downloads

Circuit

robot5.jpg
robot3.JPG
IMG_3046.JPG

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.

Mounting Everything on the Chassis

IMG_3048.JPG
IMG_3058.JPG
IMG_3052.JPG

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.

How to Operate It

putty.JPG
Capture.JPG
25.JPG

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

Controlling From a Phone

Screenshot_20171112-123755.jpg
Screenshot_20171112-123133.jpg
Screenshot_20171112-123150.jpg

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.

Some Pictures and Videos

Robot Webcam Recording
Raspberry Pi Robot
Raspberry Pi Wifi Video Streaming Robot
Screenshot_20171112-125313[1].jpg
Screenshot_20171112-125402[1].jpg

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.