NewPing Library: HC-SR04, SRF05, SRF06, DYP-ME007, Parallax PING))) - v1.7

gandalf50:
Hi Tim.

Thanks for a great library!

I have a problem though that you might have some ideas on what I've done wrong.
When using your lib (v1.5) together with an Ethernet shield, I can't get 3 sensors to work properly.

E.g:

  • If I use 3 HC-SR04 sensors and a Mega 2560 with your example code with an sonar array, they all work fine, but if I just add an Ethernet shield to the Mega, 2 of the sensors give bad readings (like 4 cm instead of 90-150cm). The same wiring is used and no code is changed, just added the Ethernet shield (i.e. not messed with Timer2 and don't use the tone lib)

  • The Ethernet shield works, e.g. can just load other code (e.g. web server code, NTP client etc) without even removing the connected sensors and it works fine, i.e. it's not the Ethernet shield itself (have also tried with another Ethernet shield with same result)

  • I've stayed away from the 50-53 pins (used by Ethernet shield+HW ss pin) and the PWM pins. Currently using pin 30-35 (it's the middle HC-SR04 that gives OK readings when Ethernet shield is connected)

  • Tried with stuff like disabling SD SPI interface, pin 4, and setting pin 53 to output without any luck.

  • Using Arduino 1.0.2 IDE

Any ideas?

Thanks in advance!!
/Magnus

First, try using different pins for the sensors that are not working. It sounds like a conflict. If that doesn't work, you're going to need to provide some code so I know exactly how you're using NewPing. Not even sure what method of NewPing you're using, timer interrupt method or standard? At least part of the code would be helpful (maybe all of it).

Tim