Getting readings from a sonar range finder

I am a software developer getting into hardware, so please excuse me if what I did was totally idiotic!

I have a MB1010 LV-MaxSonar-EZ1 Range Finder that I would like to use for a parking distance device. I thought that I could use Tinker to get some initial readings from the sonar. I soldered pigtails to the +5, GND, and PW pins on the MB1010. I connected that to the 3.3v, GND, A0 pins respectively on the core. Using Tinker I set the A0 pin to analog read and saw a value of zero.

I’m obviously doing something wrong, but not sure what. Any pointer would be appreciated.

Thanks,
Geoff

Hi @gtb104

The PW pin is the pulse output–I think you meant to use the AN pin which is the analog output.

The MB1010 has PW and analog output per the spec sheet. I thought that PW was analog, but incase it was digital, I also tried using the D0 input on the core. Still no readings when setting D0 to digital read.

Hi @gtb104

To read the PW pin, which is the pulse width output, you need to wait for a rising edge and then count the time that PW stays high to get the distance.

That whole process takes 49ms so I am not sure how you are going to see that on a plain digital input.

Try the AN pin on A0 for Tinker.

I added a lead for the AN output on the sensor and connected it to the A0 pin on the Core. Voilà, I am getting readings. The numbers I’m getting don’t really seem to jive with the distance I’m using for testing, but I can look at that later. Basically, powering the sonar with the 3v3 pin produced really jumpy numbers. The 3v3* is much more consistent. They both, however, are provide voltages that don’t seem to match the distance at the conversion rate indicated on the sonar’s spec sheet (4.6v/in).

Thanks for your help!

1 Like

I got this sensor working with Tinker so far by using D6 pin set HIGH (3.3V) and D0 set LOW pin (gnd)

Now to get JSON working…