Echo is on gpio23 and trigger on gpio 6 as per the explorer hat documentation.
When we do get a reading it is in correct.
I notice in the technical documentation for the board there is a comment about the outputs sinking current to ground when turned on and having to connect device to a voltage supply and then to the output pin.
does anyone know how this relates to the distance sensor, e.g. i have got to wire the sensor up differently, I am confuse at the moment.
If we connect the sensor direct to the PI using a potential divider on the echo pin as per the GPIO example, then it works.
A 10K pull up on the trigger solves the problem, and then invert the logic.
To generate the pulse for the trigger
output a 1 to pull the trigger low, wait 10micro secs then write a 0 to pull it high. I now get a consistent reading to less with noise of +/- 0.25 cm, more than adequate for my needs.
having sorted it, I have just seen more replies to an earlier post where they suggest the same solution.
Could you give any more details on what your circuit was and the code you used? Aiming to do something similar in the next couple of days and a pointer or two would speed things up greatly :D
Thanks Steve for solving the problem. I have modified your code to make sure the GPIO.cleanup() method is executed. Now when the program is terminated using Control + C on the keyboard, the code handles the error and cleans the GPIO allocations.