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

Let me simplify and round to make it easier to discuss. We will use your method of only 1 unit. First send out a single ping and wait up to 100ms. Each 1ms is about 1ft, 2ms round trip. Measure the integer number of msecs rounding down. Let's assume the result is near the middle between 20-21 about 20.5. We don't need to be more exact than that. Now send out 100 pings exactly 1ms apart. Measure the return values mod 1000us. This gives us the part to the right of the decimal. We already know 20ms. Average them. We might get 522us. So the answer is 20.52ms. The last 2 is not significant. Convert to feet.

You can see we don't need to identify which ping is which. It doesn't matter since they're all sent at x.000 secs. This could be relative to nothing, or GPS time. But we could figure it out since we know the object is about 20.x ms away. When a ping comes 20.51ms later we know it was sent 20+us ago, not 19 or 21.

This would not work if the object were exactly 20.01ms away, because we would hear the ping being sent each 1ms. It would be much louder and block us from hearing the echo. But it would work with 2 devices using an accurate clock! Or you could just change the interval to 1.12ms instead of 1.0ms if your echo was being blocked. More complicated math.

The advantage of my idea is that you get 100's of pings per second to average, even if the target is far away. This will let you calculate an accurate distance much quicker than waiting 100ms between sending, if you want an answer in 0.3 secs.

If you like my idea you an have it!