Ultrasonic
An ultrasonic distance sensor sends a sound pulse and measures the delay before its echo returns. For a pulse travelling to the target and back, distance = speed of sound × round-trip time ÷ 2. In dry air at 20°C, using 343 m/s and a 2 ms round trip gives about 0.343 m.
A piezoelectric transducer converts an electrical pulse into sound. The same transducer or a separate receiver detects the echo, and electronics estimate its arrival time. The frequency, burst length, processing and electrical interface depend on the sensor; an Echo pin is not universal.
In plain terms
A bat's echolocation in a chip: the transmitter cries out in ultrasound and the receiver listens for the wall's reply; the time between cry and echo converts directly to distance.
Why designers use it
- Measure liquid level in a tank without contact (blind to liquid colour or transparency).
- Give a robot bumper a non-contact obstacle-detection sense.
- Trigger a parking sensor warning before a car touches a wall.
- Count items on a conveyor belt when optical sensors are obscured by dust.
Best for
- Obstacle detection
- Level sensing
- Parking sensors
Key specifications
- Distance calculation: d = c × t / 2 for the round-trip geometry
- Usable range: Check blind zone, target and environment
- Accuracy and resolution: Different quantities; verify both
- Update rate: Allow time for echoes and processing
When not to use it
- When target angle, soft material, acoustic interference or environmental conditions prevent a reliable echo.
- Inside the sensor's blind zone or outside its documented range.
- When the selected sensor's verified accuracy, resolution or update rate cannot meet the application.
Common mistakes
- Dividing time by sound speed, or forgetting the factor of two for an out-and-back measurement.
- Confusing resolution with accuracy.
- Ignoring temperature-dependent sound speed or echoes from previous measurements.
Where you will find it
- A self-parking car uses four HC-SR04-equivalent ultrasonic sensors in its rear bumper: each sensor fans out a 15° cone, the overlap covers the full rear arc, and the body-control module synthesises a beeping rate and distance display from the four echo times as the car reverses toward a wall.
- A water-treatment plant uses ultrasonic level sensors suspended above open tanks: because the sensor is never in contact with the liquid — which may be acidic or caustic — there is no corrosion and no need for sealed penetrations, and the distance reading feeds a PID controller that maintains the tank level.
- A smart rubbish bin uses an HC-SR04 inside the lid to measure the fill level of the bin: the bin's microcontroller transmits the level over LoRa to a city-operations dashboard that plans the collection truck route, emptying only the full bins and skipping empty ones.
A short history
An ultrasonic distance sensor sends a sound pulse and measures the delay before its echo returns. The round-trip time and the speed of sound are used to calculate the target distance. This contactless approach is useful for obstacle detection, parking assistance and level sensing.
Good to know
- The factor of two accounts for sound travelling to the target and back.
- A soft or angled object can be harder to detect than a hard surface facing the sensor.