-
1Installing The Latest Raspbian Image
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!
-
2Headless Setup
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.
-
3Installing the required software (update 2018)
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.
-
4Install mjpg-streamer
sudo apt-get install libjpeg62-turbo-dev
sudo apt-get install cmake
cd
git clone https://github.com/jacksonliam/mjpg-streamer.git ~/mjpg-streamer
cd mjpg-streamer/mjpg-streamer-experimental
make clean all
sudo mkdir /opt/mjpg-streamer
sudo mv * /opt/mjpg-streamerCopy the following line in the file /etc/rc.local before the line "sudo node app.js&"
bash start_stream.sh
Remove -vf and -hf inside the file start_stream.sh to rotate the camera picture 180 degrees.
-
5Wifi Access point (optional)
Before you do this, make a backup of your SD as it is very difficult to go back to the previous state.
Download and run this script: https://gist.github.com/Lewiscowles1986/fecd4de0b45b2029c390
sudo bash Desktop/rPi3-ap-setup.sh YourWifiApName YourWifiApPassword
-
6Hardware Wiring (Standard version)
If you are unsure about voltages or connections, check with a multimeter to be safe.
-
7Changes for the ZeroBot Pro upgrade
If you want to upgrade an existing robot to the new code you can download the files from github or use:
git clone https://github.com/CoretechR/ZeroBot Desktop/touchUI
Important: The stream settings are now located in the file start_stream.sh in Desktop/touchUI instead of rc.local. This will make it necessary to remove this line which calls the mjpg-streamer on bootup:
LD_LIBRARY_PATH=/opt/mjpg-streamer/ /opt/mjpg-streamer/mjpg_streamer -i "input_raspicam.so -vf -hf -fps 15 -q 50 -x 640 -y 480" -o "output_http.so -p 9000 -w /opt/mjpg-streamer/www" > /dev/null 2>&1&
Instead, the identical code was moved to a bash file in the touchUI folder, which has to be executed. Simply add "bash start_stream.sh" to the existing call of app.js. It should looks like this in rc.local:
cd /home/pi/Desktop/touchUI bash start_stream.sh sudo node app.js& cd
This way the stream can be started by both the rc.local file on bootup and the node.js application.
Remove -vf and -hf inside the file start_stream.sh to rotate the camera picture 180 degrees.
Because of the added components, the schematic has become a little more complicated:
List of parts:
- Raspberry Pi Zero W
- 2x ICR18650 lithium cell 2600mAh
- Raspberry camera codule
- Zero camera adapter cable
- Mini DC dual motor controller
- DC gear motors
- ADS1115 ADC
- TP4056 USB charger
- MT3608 boost converter
- Raspberry CPU heatsink
- at least 8GB Micro SD card
- 2x LED
- BC337 transistor (or any other NPN)
- switch
- 4x M3x10 screws and nuts
How it should look after everything is wired up and in place:
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
Found it! Use the link from the first page, not the one on this page. Correct URL appears to be https://drive.google.com/file/d/163jyooQXnsuQmMcEBInR_YCLP5lNt7ZE/view?usp=sharing
Are you sure? yes | no
So this is working for you?
Are you sure? yes | no
It appears the "Easy Setup using SD Image" link is broken and produces a 403 error. Can someone update this please?
Are you sure? yes | no
I'm a little confused about a couple things on the robot's circuitry.
-In the build layout of the parts needed, there are 2 MT3608 converters, but it seems only one is used in the next picture and in the circuit diagram. Is the other one hidden, or simply not used?
-You're using 2 18650 batteries to power the robot, but should these be the protected variants? Additionally, do you solder your connections directly to the terminal of the battery? There seems to be no holster.
-What is the purpose of BC337?
-I plan to be retrofitting the code of this project, with your permission, to drive a tank robot with motor control being handled by a board called the Picon Zero. How does the webserver pass commands to the GPIO that powers the motor controller?
-Are the motors only receiving 4.2V from the battery? It seems that right after the switch the battery connects to the VIN on the motor driver, implying that the max motor voltage is 4.2V. Is this where the second boost converter comes in?
-I plan to use a Waveshare NVPi camera, seen here (https://www.waveshare.com/wiki/RPi_Camera_(F)). Should I modify any of the resistor values? How does GPIO 22 control the lights?
-The Adafruit Powerboost 1000C was suggested as a replacement for the MT3608 and the TP4056. This should work, but another boost converter can be used to up the voltage from the battery to the motors, correct?
I really do have a lot of questions overall, as you're a lot more fimiliar with the 3D design and coding elements of DIYing a robot than I am. Can I reach out to you somewhere?
Are you sure? yes | no
Please on which version of Node.js is it running?
Used libraries doesn't work on 10+ so I have to use NVM to install appropriate version of Node.js.
P.S.: Prepared SD card image is working at first run but is a bit dirty, you've left there many packages from OpenBox, LXDE, Minecraft and many more :)
@tyler_durden54 default password/user is same as on clean raspbian.
@Amirulmukmin It isn't supposed to be wpa_supplicant.config but "wpa_supplicant.conf" ....and on Windows be awere of Windows line breaks inside this file! Also put empty file named simply "ssh" in boot, so you have active ssh after it boots up ;)
Are you sure? yes | no
V4.8.2 of node is running on the robot that I have on my shelf. That should be the same version the sd card image is based on.
Are you sure? yes | no
Hi, Max.
i have tried to flash and put my ssid and password in wpa_supplicant.config..
when i boot the zerobot.. my raspberry blinking and stay light up... idk either it connected to my wifi or not cause i cant find the ip for that zerobot on my wifi admin and Fing apps.
how can i solve this ?
Thanks1
Are you sure? yes | no
Hi!
On the SD card image, what is the default vnc and putty login/password?
Thanks!
Are you sure? yes | no
Joystick is working fine with laptop but not working on my two mobile phones.
Are you sure? yes | no
There is a quick solution for this on the Github page: https://github.com/CoretechR/ZeroBot/issues/2
I will try to update the files as soon as possible.
EDIT: OK, all files and the SD card image are fixed
Are you sure? yes | no
I have the Zerobot built and tested. If I want to add another device with I2C protocol like distance measuring, can I just copy&paste&modify the ADS1115 I2C JavaScript files?
Are you sure? yes | no
I have solved my above question by adding a couple functions in javascript file, export these functions as a module, and called them in app.js file.
My next question; I have updated nodejs (v11) and got an error said I2C built with older nodejs version (v4.8.2). So my question is did you use 'node-gyp' to build I2C.cc addon? If not, which one did you use? Thank you!
Are you sure? yes | no
Sorry for taking so long to respond, I didn't see your previous comment. Actually I didn't build any modules, they were installed with "npm install ..." without any modifications. The ads1x15 library has not been updated in two years, so there might be some compatibility issues with later node versions. Instead of modifying or creating a library I would have just used the i2c library functions and called them in the main app.js file.
Are you sure? yes | no
Got ya. And when you said "they were installed with "npm install ..."", mean I should update I2C library after updating nodejs? Anyhow, I will try let see if it works. Thanks again, Max!
Are you sure? yes | no
What is the ADS1115 for? Can't the LEDs be powered from GPIO22 directly?
Are you sure? yes | no
It's for measuring the battery voltage (Analog -> Digital)
Are you sure? yes | no
Ah! Thanx. This is done via the LED circuit? 'Hardware' isn't my strong point...
Are you sure? yes | no
No problem. The LEDs, ADS1115 and the motor controller are connected directly to the battery,
They are connected in parallel, so each of them gets the same 3.7V from the battery.
The circuit diagram is optimized for readability. The cables in the robot can be wired differently to reduce their length. So for example you can use a wire from the LEDs to the battery and a second one from the motor controller to the battery. As long as the electrical connection remains the same that's ok.
Are you sure? yes | no
This link does not work:
https://github.com/CoretechR/ZeroBot Desktop/touchUI
Now what ??
Are you sure? yes | no
Thanks for this awesome project!
I'm a beginner so it may be a simple problem that I am having trouble with but here goes...
From GPIO22 I think that I have set up the resistors and LED's and transistor (at the top of the diagram) correctly, but I dont understand what happens after the LED's, it appears as though I am supposed to connect the positive side of the LED's to the side of the switch ...before... the boost converter lowers the voltage?
I tried this and the CPU of the Raspberry Pi got crazy hot, and does this now every time its connected to power, I'm guessing I broke it due to incorrect wiring?
Are you sure? yes | no
Hi, I'm putting together one and I wonder would it be possible to replace the TP4056 USB charger and the MT3608 boost converter by the PowerBoost 1000 Charger - Rechargeable 5V Lipo USB Boost - 1000C from adafruit? Would save some space in the box, would not it?
Are you sure? yes | no
Sure, that should work.
Are you sure? yes | no
I have a question about this. Wouldn't the power draw from the motors cause power fluctuations on the device or cause it to break if the motors are stalled? It mentions under the spec list that the max power draw is 2A.
EDIT: Nevermind, it's not wired to the motors.
Are you sure? yes | no
I have finished the last step (wifi) but im having a problem using app can you guys please help me . . .
I have setup the wifi access point and connected to the raspi but when i open the html code i cant see the camera and also cant control the motors
Are you sure? yes | no
Sorry for the late response. Have you tried installing the official SD card image to see if that works? Do you see anything on the browser screen when you connect to the Zerobot?
Are you sure? yes | no
Hi my friend , could you explain how to modify the camera resolution , in my home with wifi its very good but from anywhere with my phone on 4G i have many latency , i know to change the resolution maybe can not resolve this problem but i would like to try to check the difference :) thanks ;)
Are you sure? yes | no
Depending on the version you have installed (old Zerobot or Zerobot Pro) the line of code you are looking for is either in rc.local (in /etc/) or in the file start_stream.sh (in the folder TouchUI). The line will look like this:
LD_LIBRARY_PATH=/opt/mjpg-streamer/ /opt/mjpg-streamer/mjpg_streamer -i "input_raspicam.so -vf -hf -fps 15 -q 50 -x 640 -y 480" -o "output_http.so -p 9000 -w /opt/mjpg-streamer/www" > /dev/null 2>&1&
You can change the -x and -y parameters (640 / 480) to your resolution. Then reboot.
Are you sure? yes | no
Forgive my dumb question but just to clarify the circuit, the A0 pin on the ADS1115 is hooked to both the positive and the ground from the battery? The positive ends of the LEDs are going through 100k resistor to the A0 of the ADS1115 and from that same pin going out to the second 100k resistor and to the ground of the battery? Thank you for taking the time to keep up with the active community on here and answer questions.
Are you sure? yes | no
Yes, that is correct. The two resistors form a voltage divider: https://en.wikipedia.org/wiki/Voltage_divider
This is used to reduce the voltage on A0 (identical resistors -> factor 2 reduction).
The battery will not be shorted, only I=U/R=5V/200KOhm=25µA will flow through the resistors.
Are you sure? yes | no
Thank you for the explanation. An unrelated question: The BC337 transistor gets very hot when the lights are on. So much so that it hurts to touch. Is that normal ?
Edit: I applied a 47 Ohm resistor to the positive end of the LEDs and now the transistor does not get hot at all. Smaller values of the resistors on the positive leads do get hot as well but the 47 ohm appears to be ok. I wonder if the LEDs I have from the flashlights are drawing too much current.
Are you sure? yes | no
That's probably not right. Have you checked the wiring? Check the resistor values, too. Especially the 1.5 kOhm resistor.
Are you sure? yes | no
For the 1.5 K resistor I am instead using one 1K and 470 ohm resistors in series. I can try to increase that? When I attempt to instead use two regular sized LEDs, nothing gets hot. When I switch back to my flashlight LEDs, even one of them instead of both, the transistor gets scorching hot. There is something about those specific ones I suppose. The 47 Ohm resistor on the positive lead helps but I am still puzzled as to what to try next. I have the positive lead go to the 5V on the Pi and GND to the GND pin on the Pi as well. Would that make a difference? 3V on the Pi has the same results.
Are you sure? yes | no
You might have to use higher value resistors for the LEDs (try 100 or 200 instead of 50 ohm).
That will make the LEDs less bright and reduce the current.
For more power you probably would have to use a mosfet instead of the transistor.
Are you sure? yes | no
[this comment has been deleted]
That's very strange. At least the temperature display should always work. Have you used the provided SD card image?
Are you sure? yes | no
You might not have i2c enabled in the Raspi-Config:
https://www.raspberrypi.org/documentation/configuration/raspi-config.md
Maybe because of this the node script crashes.
Are you sure? yes | no
Is there enough clearance for headers on the boards?
I was thinking of getting a Pi Zero WH and soldering headers onto the other boards. I haven't soldered in >10 years, and working on this with my kids, so I figure that will make it easier to fix wiring mistakes.
Thanks for sharing the cool design!
Are you sure? yes | no
Sorry but the way the Pi is mounted, there is not enough clearance for the headers that are soldered to the Pi Zero WH. Attaching headers to the other boards might be difficult as well because there is little room inside the chassis. But don't despair, soldering these parts should be fairly easy. You can use any old soldering iron. Maybe try it out on some scrap circuit boards before soldering the Raspberry Pi.
Are you sure? yes | no
How difficult is it to modify the STL to take a Pi Zero with headers and a PiconZero? This is all I have available at this stage.
Are you sure? yes | no
This came up with an erro:
pi@raspberrypi:~ $ sudo apt-get install apache2 node.js npm
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package apache2 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'apache2' has no installation candidate
E: Unable to locate package node.js
E: Couldn't find any package by glob 'node.js'
E: Couldn't find any package by regex 'node.js'
E: Unable to locate package npm
pi@raspberrypi:~ $
Are you sure? yes | no
Are you connected to the internet?
Try running: sudo apt-get update
Are you sure? yes | no
apt-get update works fine in the earlier step. Is there another syntax to get the apache2?
Are you sure? yes | no
Maybe Stackoverflow will help you with that problem as It's not just related to this robot. I'm no Linux expert. I can only google you error messages.
Are you sure? yes | no
The following command does not work:
pi@raspberrypi:~ $ git clone https://github.com/CoretechR/ZeroBot Desktop/touchUI
-bash: git: command not found
Any ideas?
Are you sure? yes | no
Are you using a Lite version of Raspbian?
In that case you have to manually install git using:
sudo apt-get install git
But I would recommend using the regular Raspbian.
Are you sure? yes | no
Yes, I have Lite. i had a feeling it was due to Raspbian-lite.
Thank you
Are you sure? yes | no
it was my mistake : I had connected the motor driver after the MT3608 ! it was draining the power for the pi (i guess) everything working great now, I'm still waiting for the ADC module but so far so good. Thanks for this amazing robot :-)
Are you sure? yes | no