Technical Deep Dive 5 - Distance Sensing With HCSR04
Core Question
How can a board estimate distance without physically touching an object?
Time Of Flight
The HC-SR04 uses ultrasonic ranging. The central idea is time of flight:
- emit a pulse
- wait for the echo
- measure the elapsed time
- convert that time into distance
So the sensor is not "seeing" distance directly. It is measuring time and inferring distance from it.
Representation Matters Again
The board does not receive "near" or "far." It receives electrical signals that correspond to measured timings. Firmware then converts those timings into a more useful value, usually centimetres.
That means the sensor layer, firmware layer, and UI layer are each translating the same event differently.
Noise And Interpretation
Real sensors are not perfect. Distance readings can vary because of:
- target shape
- angle
- material
- acoustic reflections
- timing jitter
So sensing is always partly an interpretation problem, not just raw measurement.
Why This Matters
This lesson introduces one of the biggest themes in embedded systems: turning physical signals into usable data.