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

@teckel
Thanks for the explanation!, good point as I did not investigate the temperature in it.

yet the humidity, pressure, altitude, etc. makes no difference in the speed (only the temperature affects the speed).

Humidity does make a difference, too. Furthermore the effect of temperature and humidity depends on the frequency of the sound.

see this publication for the math details - http://www.rane.com/pdf/ranenotes/Enviromental_Effects_on_the_Speed_of_Sound.pdf - (updated link)

To get a optimal pulseIn you should play with Timer1 as it can count in HW in steps of 1/16 us. That's as precise as Arduino gets. Use an IRQ to get the edges of the pulse and do a diff on the countervalues. See some of my experiments in this thread - http://arduino.cc/forum/index.php/topic,96971.45.html -