Ruffydd
Posts: 2
Joined: Fri Mar 17, 2017 9:27 pm

Weird results from ultrasonic sensor

Fri Mar 17, 2017 9:57 pm

Hi,

I have a hooked up a TE501 Ultrasonic Sensor to an Arduino and then connected to a PC via the USB port. Using the Arduino IDE Serial monitor, the sensor sends consistent and reasonably accurate readings (+/- 1%).

However when I then unplug the Arduino from the PC and plug it into the USB port on my RasPi 3, and run the same Arduino code, the results in the Arduino IDE serial monitor are consistently around 20% less than the actual distance.

Please can anyone shed any light on why the same code, same Arduino, same setup would generate hugely different results when plugged into a Raspberry Pi than when it's plugged into a PC ?

Thanks for any help.

RaspISteve
Posts: 100
Joined: Wed Oct 24, 2012 9:15 pm
Location: Cheltenham, UK

Re: Weird results from ultrasonic sensor

Sat Mar 18, 2017 1:13 am

Where is the Arduino getting its power from? Maybe the PC can supply more current than the Pi and you are getting 'brown outs' causing duff readings.

Can you (or are you) running the Arduino off an independent supply?

Maybe you could reduce the problem by including a large(r) reservoir capacitor on the supply to the actual sensor to smooth out any current demand triggered voltage drops to the sensor unit.
Share and Enjoy.

Ruffydd
Posts: 2
Joined: Fri Mar 17, 2017 9:27 pm

Re: Weird results from ultrasonic sensor

Sun Mar 19, 2017 1:03 pm

Steve,

Thanks for the reply. The power for the Arduino is via a USB port. So, I have it connected to a USB port on my PC and it returns good results. I unplug the USB cable connecting the Arduino to the PC and plug the Arduino into a USB port on the RasPi, run it again and the echo times are 20% less.

I've tried using a powered USB hub on the RasPi - and connecting the Arduino to that - but there's no difference, all readings are still [consistently and in a linear fashion] 20% less than on the PC.

Really odd !

RaspISteve
Posts: 100
Joined: Wed Oct 24, 2012 9:15 pm
Location: Cheltenham, UK

Re: Weird results from ultrasonic sensor

Sun Mar 19, 2017 6:14 pm

Ruffydd,
Could still be the USB supply. If you have a couple of micro farad capacitor as a DC blocker and some earphones you could monitor/listen to the Arduino's power rails. If you've got an oscilloscope use that.

If glitches are a problem you should hear the ticks. The capacitor is to block the DC element and just give you any AC on the power rails. Omit the capacitor and risk cooking the earphones.

Another point is the Arduino's USB firmware might be slowed by other processes going on and simply missing or getting out of sync with the sensor's reporting cycle.
Share and Enjoy.

Return to “Automation, sensing and robotics”