2

my Problem is, that I get random values from my ultra sonic sensor if my arduino is connected to any external power supply (vin port 30) on my arduino nano.

If I power up from the laptop usb port, I get consistent values.

I have tested 3 different power supplies between 7-17V and up to 2000mA. I have tested this on 2 different nano boards. Also tested with an extra 2000uF capacitor between vin and gnd

pls help if you got an idea :)

  • What voltage are you reading on a +5 pin? (Ie "pin 27" in your 30-pin numbering scheme, or pin 6 on the ICSP header.) Also, what model of ultrasonic sensor do you have, and which sketch is running? And do some other sketches seem to work ok with external power? – James Waldby - jwpat7 Nov 1 '15 at 23:43
  • I got the HC-SR04 Ultrasonic Sensor and the basic demo code. I found the solution see below. Thanks for your comment anyway :) – Cracker0dks Nov 1 '15 at 23:59
3

So i tried to used a stable 5V input on the 5V input pin and got the same more or less random values (jumping all around... especially on targets more than 1m away)

So I changed form newPing lib (http://forum.arduino.cc/index.php?topic=37712.0) to Ultrasonic lib (http://forum.arduino.cc/index.php?topic=37712.0).

Now the values are correct on each power supply and even more accurate on high distance than with newPing on USB power supply.

Don't know whats broken with the newPing v1.7 lib -.- but this works!

| improve this answer | |
  • Is it possible that one library reports instantaneous values, and the other uses averaging? Or even if both use averaging, that one is synchronous with 60Hz mains? – Boggyman 2 days ago
  • the arduino side (dc) don't has access to the mains frequency (ac), so I don't think this is the difference. The only obvious difference seems to be the ground level as @SDsolar wrote below. I don't have access to my setup anymore but you could test this by temp connecting main ground to the arduino gnd and see if the values change. – Cracker0dks yesterday
1

Glad the library helped.

I think perhaps the problem had to do with reference voltages.

If you are using two supplies, you need to make sure they are grounded together very well.

One library could stand the different voltages and the other couldn't.

But the key to using two power supplies for anything is to make sure they are grounded together.

| improve this answer | |
0

I've been facing this problems as well. Different readings with different power supplies. In fact, i get wrong readings with a good 5v 2A power supply, but get good reading with a cheap 5v 1 A power supply. Not sure why this is happening. Similar results with ultrasonic library mentioned above as well.

| improve this answer | |
New contributor
user70295 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • as I wrote above, this seems to be a floating ground thing. On the good supply the mains ground is routed through to the arduino (-) ground so it is not floating. I would have expected to get invaild readings in floating condition, but it seems to be the other way around. On pc USB you also have proper ground and you also get invalid results with newPing. – Cracker0dks yesterday

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.