electronicman
Posts: 30
Joined: Mon Dec 10, 2012 9:31 pm
Location: USA

Ultrasonic sensor on raspberry pi zero

Mon Jun 20, 2016 2:56 pm

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.
David

User avatar
mikronauts
Posts: 2732
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: Ultrasonic sensor on raspberry pi zero

Mon Jun 20, 2016 5:16 pm

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.
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

User avatar
joan
Posts: 14472
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Ultrasonic sensor on raspberry pi zero

Mon Jun 20, 2016 5:22 pm

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.

electronicman
Posts: 30
Joined: Mon Dec 10, 2012 9:31 pm
Location: USA

Re: Ultrasonic sensor on raspberry pi zero

Mon Jun 20, 2016 8:02 pm

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.
David

User avatar
mikronauts
Posts: 2732
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: Ultrasonic sensor on raspberry pi zero

Mon Jun 20, 2016 8:38 pm

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.
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

Return to “Automation, sensing and robotics”