Time-of-Flight and Temperature Drift

Ada re-derives this chapter’s own numbers step by step, at full precision

foundations
math-foundations
calculation-audit
sensors
Ada ADA · CALCULATION AUDIT

Time-of-Flight and Temperature Drift

The HC-SR04 ranging widget assumes a fixed 343 m/s speed of sound at 20°C, while the chapter’s own note says sound speed adds about 0.606 m/s for every degree above a 331.3 m/s baseline, adding up to roughly a 1 cm error for every 30 cm of range if temperature is ignored. This audit asks the question that claim invites: for a worked ultrasonic pulse, does the arithmetic really produce about 1 cm of drift per 30 cm once the 0°C and 20°C speeds are compared directly?

Companion to the chapter Lab: Light and Proximity Sensors — every number here comes from that chapter.

Ada: The ultrasonic distance in this chapter is a division by two and a speed-of-sound term, and the chapter claims a ~1 cm error per 30 cm if temperature is ignored. Let me work the round trip at full precision. The rule is d = t x v / 2, with v = 343 m/s = 0.0343 cm/us at 20 C.

The worked pulse of t = 1750 us:

  • d = 1750 x 0.0343 / 2 = 60.025 / 2 = 30.01 cm.

Now let temperature move the speed, v = 331.3 + 0.606 x T:

  • At 35 C: v = 331.3 + 0.606 x 35 = 331.3 + 21.21 = 352.51 m/s, i.e. (352.51 - 331.3) / 331.3 = 6.4% faster than the 0 C baseline.
  • At 0 C the speed is 331.3 m/s = 0.03313 cm/us, so the same 1750 us pulse reads 1750 x 0.03313 / 2 = 28.99 cm.
  • Error against the 20 C value: 30.01 - 28.99 = 1.02 cm on a ~30 cm target – the chapter’s “1 cm per 30 cm.”

The audit makes the sensitivity concrete: the divide-by-two is exact geometry, but the v term carries every degree of air temperature straight into the distance, so an outdoor ranger without a thermometer bakes in a systematic 3-4% error that no averaging can remove.

Every number above is taken from the chapter’s own material and re-derived step by step.