Raspberry Pi Zero 3D Printed Video Streaming Robot
To make the experience fit your profile, pick a username and tell us what interests you.
We found and based on your interests.
For the Zerobot robot there are different instructions and files spread over Hackaday, Github and Thingiverse which may lead to some confusion. This project log is meant as a short guide on how to get started with building the robot.
Where do I start?
- Raspberry Pi Zero W - 2x ICR18650 lithium cell 2600mAh - Raspberry camera module - Zero camera adapter cable - Mini DC dual motor controller - DC gear motors - ADS1115 ADC board - TP4056 USB charger - MT3608 boost converter - Raspberry CPU heatsink - Micro SD card (8GB or more) - 2x LED - BC337 transistor (or any other NPN) - 11.5 x 6mm switch - 4x M3x10 screws and nuts
The robot spins/ doesn't drive right
The motors might be reversed. You can simply swap the two wires to fix this.
I can't connect to the Zerobot in my browser
The Raspberry Pi itself with the SD card image running on it is able to display the user interface in your browser. There is no additional hardware needed, so this can't be a hardware problem. Check if you are using the right IP and port and if you inserted the correct WiFi settings in the wpa_supplicant.conf file.
I see the user interface but no camera stream
Check if your camera is connected properly. Does it work on a regular Raspbian install?
Zerobot and Zerobot Pro - What's the difference?
The "pro" version is the second revision of the robot I built in 2017, which includes various hardware and software changes. Regardless of the hardware the "pro" software and SD-images are downwards compatible. I'd recommend building the latest version. New features like the voltage sensor and LEDs are of course optional.
Can I install the software myself?
If you don't want to use the provided SD image you can of course follow this guide to install the required software: https://hackaday.io/project/25092/instructions You should only do this if you are experienced with the Raspberry Pi. The most recent code is available on Github: https://github.com/CoretechR/ZeroBot
All new features: More battery power, a charging port, battery voltage sensing, headlights, camera mode, safe shutdown, new UI
The new software should work on all existing robots.
When I designed the ZeroBot last year, I wanted to have something that "just works". So after implementing the most basic features I put the parts on Thingiverse and wrote instructions here on Hackaday. Since then the robot has become quite popular on Thingiverse with 2800+ downloads and a few people already printed their own versions of it. Because I felt like there were some important features missing, I finally made a new version of the robot.
The ZeroBot Pro has some useful, additional features:
If you are interested in building the robot, you can head over here for the instructions: https://hackaday.io/project/25092/instructions
The 3D files are hosted on Thingiverse: https://www.thingiverse.com/thing:2800717
Download the SD card image: https://drive.google.com/file/d/163jyooQXnsuQmMcEBInR_YCLP5lNt7ZE/view?usp=sharing
After flashing the image to a 8GB SD card, open the file "wpa_supplicant.conf" with your PC and enter your WiFi settings.
After a few people ran into problems with the tutorial, I decided to create a less complicated solution. You can now download an SD card image for the robot, so there is no need for complicated installs and command line tinkering. The only thing left is getting the Pi into your network:
If you don't want the robot to be restricted to your home network, you can easily configure it to work as a wireless access point. This is described in the tutorial.
EDIT 29.7. Even easier setup - the stream ip is selected automatically now
The goal for this project was to build a small robot which could be controlled wirelessly with video feed being sent back to the user. Most of my previous projects involved Arduinos but while they are quite capable and easy to program, there are a lot of limitations with simple microcontrollers when it comes to processing power. Especially when a camera is involved, there is now way around a Raspberry Pi. The Raspberry Pi Zero W is the ideal hardware for a project like this: It is cheap, small, has built in Wifi and enough processing power and I/O ports.
Because I had barely ever worked with a Raspberry, I first had to find out how to program it and what software/language to use. Fortunately the Raspberry can be set up to work without ever needing to plug in a keyboard or Monitor and instead using a VNC connection to a remote computer. For this, the files on the boot partition of the SD card need to be modified to allow SSH access and to connect to a Wifi network without further configuration.
The next step was to get a local website running. This was surprisingly easy using Apache, which creates and hosts a sample page after installing it.
To control the robot, data would have to be sent back from the user to the Raspberry. After some failed attempts with Python I decided to use Node.js, which features a socket.io library. With the library it is rather easy to create a web socket, where data can be sent to and from the Pi. In this case it would be two values for speed and direction going to the Raspberry and some basic telemetry being sent back to the user to monitor e.g. the CPU temperature.
For the user interface I wanted to have a screen with just the camera image in the center and an analog control stick at the side of it. While searching the web I found this great javascript example by Seb Lee-Delisle: http://seb.ly/2011/04/multi-touch-game-controller-in-javascripthtml5-for-ipad/ which even works for multitouch devices. I modified it to work with a mouse as well and integrated the socket communication.
I first thought about using an Arduino for communicating with the motor controller, but this would have ruined the simplicity of the project. In fact, there is a nice Node.js library for accessing the I/O pins: https://www.npmjs.com/package/pigpio. I soldered four pins to the PWM motor controller by using the library, the motors would already turn from the javascript input.
After I finally got a camera adapter cable for the Pi Zero W, I started working on the stream. I used this tutorial to get the mjpg streamer running: https://www.youtube.com/watch?v=ix0ishA585o. The latency is surprisingly low at just 0.2-0.3s with a resolution of 640x480 pixels. The stream was then included in the existing HTML page.
With most of the software work done, I decided to make a quick prototype using an Asuro robot. This is a ancient robot kit from a time before the Arduino existed. I hooked up the motors to the controller and secured the rest of the parts with painters tape on the robot's chassis:
After the successful prototype I arranged the components in Fusion 360 to find a nice shape for the design. From my previous project (http://coretechrobotics.blogspot.com/2015/12/attiny-canbot.html) I knew that I would use a half-shell design again and make 3D printed parts.
The parts were printed in regular PLA on my Prusa i3 Hephestos. The wheels are designed to have tires made with flexible filament (in my case Ninjaflex) for better grip. For printing the shells, support materia is necessary. Simplify3D worked well with this and made the supports easy to remove.
After printing the parts and doing some minor reworking, I assembled the robot. Most components are glued inside the housing. This may no be professional approach, but I wanted to avoid screws and tight tolerances. Only the two shells are connected with four hex socket screws. The corresponding nuts are glued in on the opposing shell. This makes it easily to access the internals of the robot.
For...
Read more »DISCLAIMER: This is not a comprehensive step-by-step tutorial. Some previous experience with electronics / Raspberry Pi is required. I am not responsible for any damage done to your hardware.
I am also providing an easier alternative to this setup process using a SD card image: https://hackaday.io/project/25092/log/62102-easy-setup-using-sd-image
https://www.raspberrypi.org/documentation/installation/installing-images/
This tutorial is based on Raspbian Jessie 4/2017
Personally I used the Win32DiskImage for Windows to write the image to the SD card. You can also use this program for backing up the SD to a .img file.
IMPORTANT: Do not boot the Raspberry Pi yet!
Access the Raspberry via your Wifi network with VNC:
Put an empty file named "SSH" in the boot partiton on the SD.
Create a new file "wpa_supplicant.conf" with the following content and move it to the boot partition as well:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="wifi name"
psk="wifi password"
}
Only during the first boot this file is automatically moved to its place in the Raspberry's file system.
After booting, you have to find the Raspberry's IP address using the routers menu or a wifi scanner app.
Use Putty or a similar program to connect to this address with your PC.
After logging in with the default details you can run
sudo raspi-config
In the interfacing options enable Camera and VNC
In the advanced options expant the file system and set the resolution to something like 1280x720p.
Now you can connect to the Raspberry's GUI via a VNC viewer: https://www.realvnc.com/download/viewer/
Use the same IP and login as for Putty and you should be good to go.
sudo apt-get update sudo apt-get upgrade sudo apt-get install apache2 node.js npm git clone https://github.com/CoretechR/ZeroBot Desktop/touchUI cd Desktop/touchUI sudo npm install express sudo npm install socket.io sudo npm install pi-gpio sudo npm install pigpio
Run the app.js script using:
cd Desktop/touchUI sudo node app.js
You can make the node.js script start on boot by adding these lines to /etc/rc.local before "exit 0":
cd /home/pi/Desktop/touchUI sudo node app.js& cd
The HTML file can easily be edited while the node script is running, because it is sent out when a host (re)connects.
Create an account to leave a comment. Already have an account? Log In.
Hi !
Thanks for reply
A IP work, I have enter 192.168.1.2 in firefox and he propose to redirect me on port 3000 and interface function.
My camera don't have light is a link of my camera : https://www.google.com/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&uact=8&ved=2ahUKEwiB6MD80rfeAhVMXBoKHVPRBLMQjhx6BAgBEAM&url=https%3A%2F%2Fwww.kiwi-electronics.nl%2Fraspberry-pi-zero-w-camera-pack%3Flang%3Den&psig=AOvVaw3kSL9IcLrJKnI_35lHyb3k&ust=1541314734700685
This camera have a light to specific is in on, Do you thinks the problems is a wrong camera
Thanks for reply
You can try the usual camera beginner tutorials from the Pi foundation to see if your camera is functional. As yours seems to be a genuine Raspberry pi camera it must be compatible. The software on the SD card image was tested by many people so this can only be a hardware problem. Please make sure that the camera is correctly plugged in etc.
hi nice job so far ! Thanks a lot for this :-) ... just finished mine a few hours ago. Thinking about some modifications. Adding a speaker and a mic for bidirectional communication.... or just a speaker to play R2-D2 sounds as well ;-)
controlling this is really hard because of a large amount of initial movement torque is needed. This causes spins after first move in case of wifi latency i think.
Could you add a control option for keyboard cursor keys ?
i had a look at app.js .. but i think i´m completly wrong
So please, please, please :-) :-) :-) i`ve go a feature request :
- Arrow/Cursor keys Support for movement
Great idea! It's done: You can download the updated touch.html file from here: https://github.com/CoretechR/ZeroBot
Just replace the existing file in the TouchUI folder on the Desktop.
It would be great if you could test it to see if it works.
Wow that was pretty fast ... Thanks a lot !
just added the keyboard detection block to my Touch.html, because of i had already added some buttons for random R2-D2 Sounds and playing the Imperial March ;-)
it works great :-) in my opinion it´s much easier to control the Bot by the keyarrows. Now i can navigate just using the picture of the camera. Before it was quite difficult.
Thank you for the quick response and solution...really nice project :-)
You're welcome, thanks for the feedback. Be careful when copy/pasting the key control block into your file. I also moved the tankdrive portion of the code to the socket transmit function. Without this change the robot might not respond to short key presses.
I found the UI difficult too and replaced the original 1:48 motors with 1:90 gear reduced motors from Adafruit. https://www.adafruit.com/product/3802 . That helped, and coupled with the new TouchUI file, it's very easy to control now . El Amu - Could you post a link to your modified TouchUI file that has buttons for sounds? I think that would be a great mod for the robot.
Hello, I have installed a SD Card image but the video doesn't work, he say can't communicate with 192.168.1.2:9000, but the interface work like captor, sorry for my english I'm french student, do you know how fix problem?
Good day
It's realy a good project congrulation
Thanks! There are two possible reasons:
- The wrong IP or port was entered. Try 192.168.1.2:3000 or just 192.168.1.2
- There is a Hardware problem. Is the camera properly connected and lights up?
Hi !
Thanks for reply
A IP work, I have enter 192.168.1.2 in firefox and he propose to redirect me on port 3000 and interface function.
My camera don't have light is a link of my camera : https://www.google.com/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&uact=8&ved=2ahUKEwiB6MD80rfeAhVMXBoKHVPRBLMQjhx6BAgBEAM&url=https%3A%2F%2Fwww.kiwi-electronics.nl%2Fraspberry-pi-zero-w-camera-pack%3Flang%3Den&psig=AOvVaw3kSL9IcLrJKnI_35lHyb3k&ust=1541314734700685
This camera have a light to specific is in on, Do you thinks the problems is a wrong camera?
Hi, really cool project. Does it have an option to control robot remotely (via internet)? Smartphone app might be a good option
You can open a port in your router to control the robot from anywhere. I have not tested this myself but it should work.
what gauge wire is used, and do you have a cumulative parts list for the zerbot pro, i may have just missed it, but i think i got all the parts based off the schematic,
can the way the motors are used be modified im planing on reusing a rc car. and one motor controls right left and other is drive. this is the 2nd zerobot ill be doing
That's not too difficult to implement. Look for the tank function in the HTML file. You just have to replace that with regular car controls instead of tank controls.
Hello Max, I'm trying to replicate your excellent project, but when I try to move the joystick the motors do not move. There are no signals on the GPIO pins. The other options (video, telemetry, light) work fine. I used the latest image of the SD card - ZeroBotProWifi.img (06-14-2018). When manually installing on a clean Raspbian, the result is the same. This is not a hardware problem, when I use the old SD image - ZeroBotWifi.img (07-29-2017), motors work normally.
That is very odd. I just tested both the older version of the image and the latest one (ZeroBotProWifi.img from dropbox) and both work just fine. I am probing the motor pins on a Pi 3B with a multimeter and they show the correct voltages when I'm moving the joystick. I flashed the latest one twice to be sure. I can't access a Pi Zero right now, but there should be no difference.
I have not heard of anyone else having this exact problem. Maybe you can try the usual and download the image file again and use a different SD or Raspberry Pi to really rule out any hardware causes.
Hello Max, thanks for the answer. I reloaded the image, used a new SD and Raspberry pi 3 (the other Zero I do not have) the result is the same. There may be a problem on the browser side. When I tested the old SD image ZeroBotWifi, I watched the animation. When I clicked the mouse (or a finger on the touch screen) into the center of the joystick and moved it, the center ring moved behind the pointer. In new version (ZeroBotProWifi), the center of the joystick is highlighted, but it does not move. I tried IE11, Chrome, Firefox, Chrome for Android. Maybe the browser requires additional settings?
Sorry, but I can't replicate this issue. For me the latest image works fine on a Raspberry Pi 3 with Android, iOS (Safari), Chrome and Edge. There are a few more things you can try:
1. In Chrome on your PC: Press F12 and go to console. Check if there are any errors listed there.
2. Access the Pi using VNC Viewer, open the console and enter:
sudo killall node
cd Desktop/touchUI
sudo node app.js
Check if there are any errors.
Hi Max, Once again a huge gratitude for the help and the deepest apologies for the empty worry . I'm an old idiot, I did not understand. This is my mistake. I had to watch to the video more closely, to understand how this works.
Hello Max,
I love your ZeroBotpro, I'll try to make one.
I've already collected most of the components except 2.
- what is the reference of the LEDs used?
- what kind of electrical wires to take (diameter, strands...)
Thx !
The robot is designed for standard 5mm LEDs.
I don't have exact diameter values for the cables. Something between AWG 22 and 20 should be safe for the motors and battery connections. The logic connections for the Raspberry Pi can be very thin. You can look at the pictures from the inside of the robot to see what kind of wires I used.
Thanks for the answer Max, I start the construction as soon as I've received all the parts!
Great project, Max! Can you provide a link to the small slider switch you used? I've struggled to find one that fits the 3d print. Thx!
Sorry, I couldn't find where I had ordered it. The measurements are 11.5 x 6 mm. Maybe you can get it from an electronics store.
thx! So far I've only located a 11.5 x 4 mm @ http://www.te.com/usa-en/product-1437575-4.html I'll keep looking :)
Thanks for the reply Max.
I just tried a few different browsers with no luck, I was using firefox first then I tried falkon and chromium with no luck. they all show http://raspberrypi:3000/ in the URL but can't connect to server. No interface is loaded & I just see a blank page or message telling me it can't connect depending on what browser I'm using.
I have re-installed the image as well. I'll start again from scratch and see how I go.
Edit: I just tried the IP address 192.168.1.2:3000 as you suggested and I see the camera output in the browser. A quick test on the phone & it seems I have the touch control functioning properly as well.
Thanks Max!
Hi
I'm trying to test this without the hardware (motors etc, they are taking ages to arrive from China) and I can't connect to the touchUI. I do have a camera connected. It seems to stop at pigpio.gpioInitialise(); . Am I right to assume it is sensing no pin voltage and not connecting due to that ?
I also left a question about this in the instruction thread for the easy setup yesterday.
https://hackaday.io/project/25092/log/62102-easy-setup-using-sd-image
Sorry for answering so late. The notifications in Hackaday.io are a bit buggy. As far as I can tell, the Raspberry in this state can't sense if it's connected to anything. You should be fine running the code on a bare Raspberry Pi. In the instructions thread you wrote that your browser can't connect to http://raspberrypi:3000/. I configured the first page with the "well done" message to automatically forward to the :3000 port that you need for controlling the robot. Have you tried connecting to 192.168.1.2:3000 directly?
Sorry I missed your reply,, thanks for getting back to me.
I did try connecting to port 3000 on the same IP address the raspi was on with no luck.. It tries to forward to port 3000 by itself and the URL bar shows the IP address appended with 3000 after the "well done" message. it just won't connect to the server on the zero.
If I connect by VNC and try to start the TouchUI in a terminal it gets to the GPIO intialisation phase and returns an error and stops. I had a bit of a look at the TouchUI code and thought it might have been expecting GPIO data from motor potions.etc and stopping when it didn't get any feedback due to not having anything connected.
The computer I was doing it all with died a few days ago, so I haven't been able to do any more until today. I'll do some more investigation today.
The script is already running. Manually starting it will give you errors. That's normal. And if you are using the image file there shouldn't be a software problem with the pi. You should be able to get to the user interface with just the Pi and a camera plugged in. Have you tried other browsers or reinstalled the image?
Is there an updated Fusion 360 link for the ZeroBot Pro modifications?
Does anyone know of a quieter alternative to those motors and gears? They seem to be noisy from videos I see on youtube.
I dont read the hole discussion .......is there a way to bind it via Internet ? That i can use it as a mobile security cam .......and the goal is to bind it to my OpenHab
Nice work ! Love it!
If you want to control the robot via the internet you need to forward ports 3000 and 9000 on your router. But I haven't tested this myself. There probably are tutorials on how to do this for a Raspberry Pi in general.
My OpenHab runs in a Pi with forwarding ....i thought that the Pi in the zerobot generate a single Network without a Router .....okay If its so easy .......i turn my printer on 😊
Another Idea is to add a inductive charging station .....there many chinese induction chargers in the bay....so the bot can wait the most time on the station and when i connect it from my Holiday Hotel its ready to go
May I add a suggestion that you resize the image you provide. The unexpanded image is 8.07GB and while I used an 8GB sd card to copy it to, the card is actually 7.95GB and the copy ends with an error. I copied it to a 16gb card and looking at the space, it only uses 3.4G. If you got a 4GB sd card, you could use the SD Card Copier (Raspberry Menu->Accessories-SD Card Copier) to put it on the smaller card, then image that card. This would speed up downloads and it would fit on any 8GB sd card.
Thank you for the idea! I tried using PiShrink earlier (https://github.com/Drewsif/PiShrink) but that didn't work. I have never used the SD card copier, that's probably a much better solution. But I don't think it will affect the download size, the zip compression already takes care of all the empty space.
I enjoy this project very much. Good work here.
I can't seem to get the page to load on my android device on any browser (Edge, Chrome, Firefox) but I can get it work fine on my desktop with Chrome. I have tried changing the setting on my android chrome to desktop version and still no luck. Also, I can't seem to be able to get any feed from the camera either.
Thanks!
Are you using the SD card image or did you manually install it? The SD image usually is more reliable. If the camera image doesn't show up there is something wrong with the setup. Are you entering the port (:3000) behind the IP like 192.168.2.4:3000? Have you tried another device? For me it's working fine on Windows, iOS and Android.
Hello , i realy like this project , verry good job !
But i am beginner with raspberry pi , i respect step by step tutorial but when i run the app.js script i have this message :
pi@raspberrypi:~/Desktop/touchUI $ sudo node app.js
/home/pi/node_modules/socket.io/lib/index.js:177
const keysIterator = this.parentNsps.keys();
^^^^^
SyntaxError: Use of const in strict mode.
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/home/pi/Desktop/touchUI/app.js:3:10)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
could you help me please ? :)
Did you run the script after a reboot? The code in the rc.local file calls the node scipt automatically. If you run it a second time that may lead to errors although it's already working in the background. You can also try "sudo apt-get update" and see of that helps.
If you are a total beginner I would recommend you to use the SD card image instead of the manual install.
oh ! many thanks ! , in fact i use since the start your sd card image but after i make all manipulation of your tutorial but its not necessary ^^ , now that work , im happy lol
Hello my friend
congratulations for your job!!
I installed and mounted everything and I followed the installation instructions via VNC without errors .... my router sees zerobot at the address 192.168.1.4 I click on the link and then gives me a page error not found .......but I do not know why ?? the wiring is ok ... I do not really see the html page :( ......I'm sorry but I understand little of linux commands ...
Have you tried entering the port behind the ip address like this?
192.168.1.4:3000
Thanks for putting all this work into making this project accessible to others. I finally got mine to work last night. In you opinion, how hard would it be for someone with no coding experience to add a pan tilt servo movement to the camera and implement it into your code? I can follow tutorials on pan/tilt servo movement with plenty of resources online but implementing the control into your modified UI seems intimidating. Do you have any tips for me or any bits of advice as I venture into this? Thanks again!
Interesting! A good place to start would be Seb Lee's multitouch example, that I used as a base for my interface: http://seb.ly/2011/04/multi-touch-game-controller-in-javascripthtml5-for-ipad/
On his website is an example where the left side of the touchscreen is used as a joystick and the right as a button for shooting. You would have to implement a second joystick for the right side instead of this button.
I have prepared this for you:
https://drive.google.com/file/d/1h302oW-rB5X-Or0XyqRSEptGoJcSReeV/view?usp=sharing
It should work on pc and touch devices but I'm not sure if multitouch is functional.
The html will "send" two more values for pan an tilt next to the motor control values. You will only have to modify the app.js file to receive these values.
Thank you so much for this! I very much appreciate it. I am very excited to try all this out soon.
One more question not relating to the above. I am attempting to update the existing code to run the upgraded version of zerobot. Step one of that process you listed is to GIT clone the touchUI. However when I run that command I get informed that the folder touchUI already exists and contains files. What is the correct way to update it? I attempted to simply delete the old touchUI folder on the desktop and replaced it with the new. This however bricked the whole thing. I would love your advice on how to proceed from here. Thank you.
The easiest way is probably to install the new sd card image instead of trying to update the older one. The update should usually work however.
Become a member to follow this project and never miss any updates
By using our website and services, you expressly agree to the placement of our performance, functionality, and advertising cookies. Learn More
339/5000
Hello, a great project. My ZeroBot works wonderfully. However, I have no housing, but looks good too.
I control the ZeroBot on the way normally over the Browser. You just have to establish a VPN connection to the home router. Works wonderfully. Or only the camera stream on the port release of port 9000.