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

Timbergetter:
I am using a single JSN-SR04T-2.0 with the NewPing 1.9.0 library on a stand alone Atmega 328P.
For testing I am cycling through 10 pings with a 200 ms delay between each call. If I use the simple ping() function I get good time results (all result values within 1% or so). If I use the ping_cm() function the distance results can vary wildly. (eg 125, 126, 64, 125, 63, 63 etc). I get the same experience after swapping to another of these sensors and to another of these sensor interface cards. Do you have any idea why I could be getting such different consistency results when comparing ping() and ping_cm()?

My guess is that you setup a variable which is rolling over. You can just do:

sonar.ping() / US_ROUNDTRIP_CM

which is the same as ping_cm().

Tim