As is known, the speed of sound depends of temperature and Relative Humidity. I'm trying to calibrate HC-SR04 sensor taking account these factors.

In SparkFun page there is no mention about environmental conditions in calibration (only is informed that speed of sound is 340 m/s). I found a paper with some calibration, but again it is no mention of original conditions.

I'm using the time elapsed per response to calculate distance in Arduino with access to a temperature & humidity chamber, so I want to recreate the calibration conditions to probe if the sensor is accurate.

Anyone know the environmental conditions of HC-SR04 calibration?

  • You are over thinking things. The difference is so small, and the accuracy of the HC-SR04 (especially when coupled with the Arduino) so poor that any "calibration" would be meaningless.
    – Majenko
    Sep 29, 2017 at 19:07
  • @Majenko Based in this research, difference between raw / temperature calibrated data is significant. My aim is to use it measuring water level in small reservoirs and pan evaporation for agriculture, so outdoor condition can affect significantly the output data and, consequently, farmer decision
    – aldo_tapia
    Sep 29, 2017 at 19:14
  • How small? You are aware of the range limitation of those units?
    – Majenko
    Sep 29, 2017 at 20:15
  • 1
    The humidity might make like a 0.5% difference in the measurement. At the range you're talking about I have my doubts that the Arduino would even be able to measure the difference in time. Even if it could, you're talking about a difference of sub-millimeter proportions. How accurate does the measurement really need to be? I don't think the unit itself is that accurate on the timing to begin with.
    – Delta_G
    Sep 29, 2017 at 21:47
  • 1
    @Delta_G could be. I will make different tests prior to check the effect of HR. But temperature has a measurable effect tested in fixed distance. At the moment, corrected data has a lower standard deviation
    – aldo_tapia
    Sep 29, 2017 at 22:44

1 Answer 1


The HC-SR04 is not calibrated, nor does it take any measurements.

All it does is allow software on a connected microcontroller or system like an Arduino to measure the sum of the round trip time delay and some small internal offset delay, and from this calculate distance.

As the timing and calculation are entirely in your program, calibration is entirely up to you.

Under known conditions you could measure both a short and a long distance. This would give you a slope and intercept - the slope from the speed of sound (which should not depend on the device at all, only on the conditions and your timing reference), and the intercept or offset, having to do with latencies in the system.

You could then cross-check at other distances, but under fixed conditions behavior should be linear.

As there is some initial ringing of the sender which can couple to the receiver and be mistaken for an echo, there will be a minimum distance below which you cannot reliably take a reading - as a guess, this is more than 5 cm, but you'll have to see, and it may even vary a little from unit to unit.

To a degree, it's a little bit amazing that these even work. They use an RS232 level shifter to generate transmit pulses, and it's been alleged that the receive circuit is horribly mistuned, not really matching the emitted frequency at all... but despite that they do seem to work fairly well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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