Posts: 10
Joined: Sun Apr 21, 2019 9:21 am

Issue with ultrasonic sensor

Thu Jun 06, 2019 11:10 pm

Having some issues getting the DFRobot weatherproof ultrasonic sensor (https://core-electronics.com.au/weather ... probe.html) set up with a Raspberry Pi Zero. I have tried several configurations and variants of code and am getting either unusual or no results.

For example:

using gpiozero and the setup and code from https://projects.raspberrypi.org/en/pro ... mputing/14 I get a stream of similar measurements in the 17-18cm range irrespective of distance.

using https://pimylifeup.com/raspberry-pi-distance-sensor/ It reaches print(“Calculating distance”) and then does nothing

using https://www.raspberrypi-spy.co.uk/2012/ ... on-part-1/ just hangs

With the second setup from pimylifeup, I achieved one single reading which looked successful.

The ultrasonic sensor is also acting strangely. The LED has, at various times, lit up and stayed lit, flickered to indicate trigger at appropriate times but still returned no distance, and stayed dark. There have also been several occasions where the ultrasonic device has been emitting a constant sound.

Any suggestions welcome!


Re: Issue with ultrasonic sensor

Fri Jun 07, 2019 12:19 am

A few questions:

1) The device states 5V - how have you connected it to the Pi?
2) There is no documentation - the WIKI has nothing under 'weatherproof' and nothing seems to match the 'ultrasonic' results - other than the review - how do you know it works with a Pi?
3)The software you linked to may have a different sensor module than this one. How do you know they are compatible?
4) Any idea what the pot on the board does?

A known problem with some sensors is a minimum distance reading - is the 17-18cm due to that?

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

Re: Issue with ultrasonic sensor

Fri Jun 07, 2019 6:49 am

Power from 5V. You need to use a voltage divider on the echo line to drop 5V to 3V3.

A clear photo and description of the connections between Pi and sensor will be useful.

I also suggest piscope so you can check the trigger/echo lines.


Posts: 282
Joined: Wed Jun 20, 2012 2:51 pm
Location: Southampton, England

Re: Issue with ultrasonic sensor

Fri Jun 07, 2019 8:27 am

Which version of GPIOZero are you using? Before v1.5 there were problems with the DistanceSensor code on Zeros, although other models seemed to work better.

Posts: 11070
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Issue with ultrasonic sensor

Fri Jun 07, 2019 8:30 am

Looking at the product wiki page for this sensor https://wiki.dfrobot.com/Weather_-_proo ... ___SEN0208

It stats the operating range is : 25cm ~ 4.5m so its not supposed to operate at ranges under 25 cm so the fact that you are getting ranges of 17-18cm range I would say you are operating outside of the sensors operating range, hence the strange results/problems.

And as joan said you need to reduce the 5v output to a safe 3.3v before you connect it to the pi gpio I suggest a simple potential divider made from 2 resistors.

Some thing like this

We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Posts: 1
Joined: Thu Jun 13, 2019 6:13 am

Re: Issue with ultrasonic sensor

Thu Jun 13, 2019 6:18 am

Hi there,
We are sorry for the less information.
https://wiki.dfrobot.com/Weather_-_proo ... ___SEN0208
If you want to know more information, please email to techsupport@dfrobot.com to tell the tech supporter what information you want to know.

Return to “Automation, sensing and robotics”