Page 1 of 1

Ultrasonic sensor on raspberry pi zero

Posted: Mon Jun 20, 2016 2:56 pm
by electronicman
I have been trying an ultrasonic sensor, HC-SR04, on various versions of the Pi. With any of the large board Pi's the sensor gives me a maximum range of about 100cm, however, when using a Pi Zero it only gives me a max range of about 50cm. I recently got the latest version of the Pi Zero, and have the same result.

Does anyone have the same problem, or does anyone have any ideas as to why the range would be less with the Pi zero all things being equal.

Re: Ultrasonic sensor on raspberry pi zero

Posted: Mon Jun 20, 2016 5:16 pm
by mikronauts
See http://www.mikronauts.com/robot-zoo/elf-2wd-pi-robot/4/

You have to power the HC-SR04 from 5V, then divide the ECHO output down to be 3.3v safe.

The software is also a bit tricky.

Re: Ultrasonic sensor on raspberry pi zero

Posted: Mon Jun 20, 2016 5:22 pm
by joan
There is no reason at all.

You need to power the sensor with 5V and use a voltage divider to cut the echo signal down from 5V to a Pi safe 3V3 as mentioned by mikronauts.

http://abyz.co.uk/rpi/pigpio/examples.html#pdif2_SRTED should work.

Re: Ultrasonic sensor on raspberry pi zero

Posted: Mon Jun 20, 2016 8:02 pm
by electronicman
The Zero is powered with 5 Volts and the echo signal is passed thought a voltage divider to give 3.3 volts to the appropriate pin on the Pi. Although it does look like the voltage may be low somewhere.

Re: Ultrasonic sensor on raspberry pi zero

Posted: Mon Jun 20, 2016 8:38 pm
by mikronauts
The HC-SR04 also needs to be powered with 5V
electronicman wrote:The Zero is powered with 5 Volts and the echo signal is passed thought a voltage divider to give 3.3 volts to the appropriate pin on the Pi. Although it does look like the voltage may be low somewhere.