Ultrasonic ranging looks simple: emit a sound pulse, wait for the echo, and calculate distance. In practice, the reading may jump, disappear, or lock onto a nearby object that is not the object you care about.
The safer first model is: an ultrasonic sensor measures the round-trip time of an acoustic echo. The reported distance is an interpretation that assumes the echo came from the intended target and that sound speed and geometry are reasonable.
Emit ultrasonic pulse
-> Sound propagates through air
-> Target surface reflects part of the sound
-> Receiver detects echo
-> Distance = sound_speed * time_of_flight / 2
The division by 2 is necessary because the sound travels to the target and back.
What It Really Measures
The sensor does not measure the target directly. It measures the time between a transmit pulse and a received echo. The distance calculation assumes:
- The echo came from the intended surface
- The sound speed is known
- The path is roughly straight
- The sensor chose the correct echo among multiple echoes
If any of those assumptions fail, the distance can still be a valid echo distance but not the distance you wanted.
Why Use Ultrasound
Reflection is not unique to ultrasound. Any sound wave can reflect when it meets a boundary with different acoustic impedance.
Ultrasound is useful because its frequency is high and its wavelength is short. A common air ultrasonic module works around 40 kHz. At room temperature, its wavelength is roughly:
wavelength = sound_speed / frequency
With sound speed around 343 m/s, 40 kHz gives about 8.6 mm. A 1 kHz audible sound has a wavelength around 34 cm.
Shorter wavelength helps make a small transducer more directional and makes nearby echoes easier to separate. That is why practical distance modules commonly use ultrasound rather than audible sound.
Sound Speed Is Not Constant
The basic formula is:
distance = sound_speed * flight_time / 2
In air, sound speed depends mainly on temperature. A common approximation is:
sound_speed ≈ 331.3 + 0.606 * temperature_celsius
At 20°C, this is about 343 m/s. If temperature changes and the algorithm still uses a fixed sound speed, the distance estimate shifts. Humidity and air composition can also matter, but temperature is usually the first-order correction in ordinary device scenarios.
The Beam Is Not a Flat Fan
Ultrasonic modules do not emit an infinitely thin line. They emit a three-dimensional acoustic beam. People often describe it as a fan, but the real field is a spatial lobe with side lobes, near-field effects, and transducer-specific patterns.
Anything inside the effective beam can reflect sound:
- The intended target
- The floor
- A wall edge
- A table leg
- A pipe or railing
- A nearby cover or enclosure opening
The receiver may get multiple echoes. They are not “the same content”; they are echoes from different surfaces and paths, arriving at different times and strengths.
The system then has to decide which echo is valid. The first strong echo is not always the right target.
Target Surface Matters
Ultrasonic ranging works best on large, hard, flat surfaces facing the sensor.
It becomes unreliable when the target is:
- Soft and absorptive, such as fabric or foam
- Angled, reflecting energy away from the receiver
- Too small or thin, such as a rod or wire
- Curved, such as a ball or rounded bollard
- Irregular, such as grass, snow, gravel, or a pile of objects
This is why reverse parking sensors can misread cones, spherical stone posts, thin poles, low curbs, soft vegetation, or sloped surfaces. The sensor is reacting to echo quality, not understanding object identity.
Blind Zone and Residual Ringing
An ultrasonic transducer keeps ringing for a short time after transmitting. If the target is too close, the echo returns while the transducer and front end are still recovering.
That creates a blind zone. Software can use time windows and filtering, but it cannot completely remove the physical near-field limit.
The enclosure also matters. If the acoustic opening is too small, recessed, blocked by water, mud, ice, or decorative structure, the outgoing pulse and returning echo are both distorted.
Why Readings Jump
Common causes include:
- Multiple echoes from floor, wall, and target
- Target angle changing the strongest reflection path
- Soft or rough material absorbing sound
- Temperature changing sound speed
- Nearby structures entering the beam
- Mechanical vibration from motors or fans
- Blind-zone echoes near the transducer
- Algorithm switching between echo candidates
The sensor may be working correctly at the acoustic level while the interpreted distance is unstable.
Mounting Structure Often Matters More Than the Module
A good module can perform badly when the acoustic path is poorly mounted.
Common mounting problems include:
- The transducer is recessed too deeply
- The case opening forms an acoustic tube
- The cover blocks part of the beam
- Water, mud, dust, ice, or paint changes the opening
- The module is tilted relative to the target
- Nearby walls or brackets enter the beam
- Vibration from motors, fans, or relays couples into the transducer
For reverse parking sensors and small robots, the enclosure is part of the acoustic system. It cannot be treated as decoration.
Sampling and Filtering Cannot Replace Echo Quality
Averaging, median filters, and outlier rejection can make readings look smoother. They cannot recover a missing or wrong echo.
If the sensor alternates between a target echo and a floor echo, filtering may hide the jump but introduce latency or wrong intermediate values. If the target absorbs sound, no filter can create a reliable echo.
Filtering should be used after the physical echo path is reasonable.
Debugging Checklist
When ultrasonic readings are unstable, check:
- Is the target large, hard, and roughly perpendicular?
- Is the target inside the blind zone?
- Does the beam include floor, wall, or nearby structures?
- Is the temperature compensation reasonable?
- Is the enclosure opening distorting the beam?
- Is there mechanical vibration?
- Are multiple echoes being selected inconsistently?
Engineering Takeaway
Ultrasonic ranging is useful, cheap, and robust in many short-range cases, but it should not be treated as a perfect object detector.
It is good for:
- Tank level or height measurement with stable geometry
- Short-range obstacle detection
- Presence of large hard targets
- Simple distance estimation where environment is controlled
It is weak for:
- Thin, soft, curved, angled, or absorbent objects
- Complex scenes with multiple reflectors
- Very close targets inside the blind zone
- Safety decisions that require object recognition
The key sentence is:
Ultrasonic sensors measure echo flight time.
Distance is valid only when the echo path and target assumption are valid.
That is why parking sensors help, but should not be relied on as the only source of truth.