I have built a little robot using the pi zero, explorer Phat, zumo chassis and ubec to regulate the voltage from the 4 AA batteries that the zumo chassis holds.
When battery powered the battery connects via one of the 5v headers on the explorer pHat.
I have just added an ultrasonic sensor to the robot and written some new code to analyse the readings and avoid obstacles. This works fine when connected to the raspberry pi power supply but if I power the robot up via the batteries nothing happens.
I have the script setup as a cronjob and if I connect my usb hub to the robot while its on battery power it suddenly continues with the script.
So it seems like a power issue when the new sensor is connected. I have connected the sensor to the second 5v header/ground and one of each of the input/output pins.
If someone can explain to me what is causing this and how to fix it that would be great. I am wondering if using a usb phone charger battery pack might make a difference?
I have added a photo below.
what voltage do you read across the 5v pin on the Pi header and ground? I suspect you will be below 5v and possibly the operating minimum of the sensor.
I still need to pick myself up a voltmeter but I suspect you are right.
I think I need something better than the batteries that are currently running it as these have barely been used.
I just tested the voltage its 4.9 volts.
hum… so the sensor is the only thing not working when powered from battery, i.e the motors operate normally?
motors run fine if for example I make a script just to run them forwards it sets off without delay.
I have been playing around and the robot does seem to come alive after a bit of time (a few minutes or so) with my script that includes the ultrasonic code.
It seems like it randomly manages to read the sensor and change the direction of the motors (perhaps a couple of times a minute)
P.S I have also tried this now with a 5v power bank and get the same issue. It still runs fine using the official power supply though.
This is my ultrasonic script.
while explorerhat.input.one.read() == 0:
sendTime = time.time()
while explorerhat.input.one.read() == 1:
endTime = time.time()
duration = endTime - sendTime
distance = duration * 17150
#print "Object distance: ",distance,"cm"
if distance < 20:
It is based on https://www.modmypi.com/blog/hc-sr04-ultrasonic-range-sensor-on-the-raspberry-pi