Ultrasonic Sensor: How It Works, Specs, and Which Module to Buy

An ultrasonic sensor measures distance by timing how long a burst of high-frequency sound takes to bounce off an object and return — the same time-of-flight idea behind sonar, just built into a small, low-power module. The most common hobbyist version, the HC-SR04, resolves distance from 2 cm to 400 cm with a maker-stated accuracy of 3 mm, and the same trick scales up to industrial level gauges and automotive parking sensors. This guide covers how the timing actually works, which specs matter when you pick a module, where the technology breaks down, and how it typically gets used in real projects.
How ultrasonic sensors measure distance
An ultrasonic ranging module has two transducers: one that transmits and one that listens. On the popular HC-SR04, a control pulse of at least 10 microseconds on the trigger pin makes the module send eight cycles of 40 kHz sound — above the roughly 20 kHz ceiling of human hearing — out through the transmitter. The receiver then waits for that same burst to bounce off whatever is in front of it and come back. The instant the echo arrives, the module raises its echo output pin and holds it high for a duration proportional to the total round-trip time. The manufacturer's own datasheet gives the resulting formula directly: distance equals the echo pulse's high time multiplied by the speed of sound, divided by two (to account for the sound traveling to the object and back). The datasheet even publishes a shortcut for the math: divide the echo time in microseconds by 58 to get centimeters, or by 148 for inches.
That "divide by two" step is why this family of sensor is grouped with other time-of-flight sensors that measure infrared light instead of sound — the underlying math is identical, only the wave and its speed change. Sound is far slower than light, which is exactly what makes it practical to time with simple, cheap electronics instead of the picosecond-level timing that optical time-of-flight sensors need.
Key specs to check before you buy
Every listing for an ultrasonic module quotes roughly the same handful of numbers. Here is what they mean and why each one matters for a real project, using the HC-SR04's own published figures as a concrete reference point.
| Spec | HC-SR04 datasheet value | Why it matters |
|---|---|---|
| Range | 2 cm – 400 cm | Sets the working window; anything closer or farther won't return a usable reading |
| Measuring (beam) angle | ~15° | Anything inside that cone gets detected — the sensor can't tell you where within it |
| Accuracy | ~3 mm (maker-stated) | Best-case resolution under ideal conditions, not a guaranteed tolerance |
| Trigger pulse | ≥10 µs TTL | Minimum signal needed to start a measurement cycle |
| Recommended measurement cycle | ≥60 ms between readings | Caps a single unit at roughly 16 readings per second |
| Supply / current | 5 V DC / ~15 mA | Determines whether it can run directly off a microcontroller's 5 V rail |
Three of those deserve a closer look because they're the ones a shopping listing rarely explains.
Beam angle and the blind zone
The ~15° measuring angle means the sensor reports the distance to whatever is closest inside that whole cone, not a single point in space. Two objects at different angles but the same distance are indistinguishable; a narrow object off to one side can also be missed entirely if it sits outside the cone. That makes ultrasonic sensors good for "is anything in my path" detection and poor for pinpointing exactly where an object is.
The published 2 cm minimum range is effectively a blind zone: closer than that, the outgoing burst hasn't finished ringing down in the transducer before the echo would arrive, so the module can't reliably separate the two. Projects that need to detect very close objects — a robot arm's end effector, a liquid level near the top of a tank — need a module rated for a shorter minimum range, not just a longer maximum one.
Update rate and cross-talk
The datasheet's own recommendation — wait 60 ms or more between trigger pulses "to prevent trigger signal [from interfering] with echo signal" — sets the realistic top speed of a single sensor at around 16 readings per second. That limit gets worse, not better, when several ultrasonic sensors share the same space: one unit's outgoing burst can be picked up by a neighboring sensor's receiver, producing a false short reading. Staggering trigger timing between units, rather than firing them simultaneously, is the usual fix.
Typical modules: open-face vs. waterproof
The HC-SR04 and its many pin-compatible clones are built around an open pair of transducer discs on the front of a small PCB — inexpensive, easy to wire into a microcontroller project, and fine for indoor, dry environments. So many manufacturers copy its exact four-pin layout (VCC, Trig, Echo, GND) that it has become a de facto interface standard for low-cost ultrasonic ranging, which is also why it shows up in most Raspberry Pi and Arduino distance-sensing projects.
Disclosure: this article contains affiliate links. If you buy through them we may earn a small commission at no extra cost to you.
- NON-CONTACT DISTANCE SENSING: Add object detection to robot navigation, parking-distance prototypes, automatic lids, counters and interactive projects; each HC-SR04 uses a 40 kHz ultrasonic burst and echo timing to estimate distance
- 5-PACK FOR REPEATABLE PROTOTYPING: Use multiple HC-SR04 modules across builds, compare sensor positions or keep spares for testing and replacement; each module integrates an ultrasonic transmitter, receiver and control circuit
- 5 V MODULE WITH 3-450 CM RANGE: Connect VCC, Trig, Echo and GND, use a 10 µs trigger pulse and measure Echo duration; resolution is 0.3 cm with an effective angle under 15°, while the controller board and external power source are not included
- PROTECT 3.3 V GPIO: The HC-SR04 operates from 5 V and its Echo output is 5 V, so use a voltage divider or suitable level shifting with 3.3 V inputs; keep the module dry and use it for prototyping rather than calibrated measurement
- FOR ROBOTICS & STEM PROJECTS: Suitable for distance measurement, object detection, automatic lids, parking alerts, robot navigation and other hands-on electronics builds
For anything outdoors, in a humid enclosure, or pointed into a tank, an open-face module is the wrong choice — water on the transducer disc changes how it resonates and corrupts the reading, and the exposed PCB has no protection at all. That's what waterproof, probe-style modules are for: the transducer sits inside a sealed, epoxy-potted probe on the end of a cable, so the electronics stay dry while only the probe faces the liquid or the weather.
- With a waterproof sealed emitter. This sensor is suitable for outdoor applications such as car reversing sensors, security alarms, industrial inspection, etc.
- Integrated with wire enclosed waterproof probe, suitable for wet, harsh measurement occasions. Please note that the device is waterproof, but it couldn't work underwater.
- Working voltage:DC 5V, Static current:5mA, Total current work: 30mA. Working range: 25cm-4M, Working frequency: 40KHZ, Detecting angle: 70 degree.
- The module has a variety of modes that can be modified manually, suitable for testing and teaching experiments in different occasions.
- Application: Horizontal distance messurement,Obstacle avoidance, automatic control, Traffic control, Security, industrial control.
Where ultrasonic sensors struggle
Two failure modes come up constantly, and both trace back to how sound behaves rather than to a specific module being cheaply made.
Soft, angled, or very small surfaces. The HC-SR04 datasheet's own installation note says the target should present a smooth surface of at least 0.5 square meters for reliable readings. Soft or fibrous materials — foam, fabric, loose insulation — absorb sound energy instead of reflecting it, weakening or killing the echo. Surfaces angled sharply away from the sensor reflect the sound off to the side (specular reflection) rather than straight back, which can produce a much longer reading than the real distance, or no echo at all.
Temperature. The distance formula assumes a fixed speed of sound, but sound genuinely travels faster as air warms up. Reference tables for dry air put it at about 331.5 m/s at 0°C, roughly 343.5 m/s at 20°C, and around 350 m/s at 30°C — a swing of nearly 6% across that range, which is also roughly the size of the error a fixed-speed module accumulates if it's used well outside room temperature. High-precision applications add a temperature sensor and correct the speed-of-sound constant in software; most hobbyist projects simply accept the error.
Common uses
Robotics is the most familiar use: small mobile robots and vacuum-style bots use ultrasonic modules as a cheap, forward-facing "is something in my way" check, often layered with the same sensor fusion techniques covered in our IMU sensors guide for platforms that also need to know their own orientation. Liquid and solid level sensing is another natural fit, because the sensor mounts above the tank or hopper and never touches what it's measuring, avoiding the fouling and maintenance that plague contact probes.
Automotive backup and parking sensors are the use case most people have physically touched, and also the clearest example of the technology's limits in practice. Tesla announced that, starting in October 2022, it was removing ultrasonic sensors (USS) from new Model 3 and Model Y vehicles, replacing the parking and object-detection functions those sensors handled with its camera-based Tesla Vision system. Tesla's own announcement described the change as giving Autopilot "high-definition spatial positioning, longer range visibility and ability to identify and differentiate between objects" — capabilities a distance-only ultrasonic reading can't provide on its own. It's a real-world illustration of the trade-off this guide keeps coming back to: ultrasonic sensing is cheap and reliable at short range, but it has no way to identify what it's detecting, only that something is there.
Choosing a module without a spec you'll regret
A shopping listing tells you a price and a star rating; it rarely tells you which of the specs above will actually bite you. Before adding one to a cart or a bill of materials:
- Match the blind zone to the closest object you need to see — if a project needs to detect something within 2 cm, the standard HC-SR04 minimum range already rules it out.
- Match the beam angle to the task. A wide cone is fine for "is the path clear"; a task that needs to know exactly where an object is within a few degrees needs a narrower-beam module or a different sensor family entirely, such as a time-of-flight unit.
- Plan for the environment, not just the room it ships to. Outdoor, humid, or liquid-facing installs need a sealed probe module, not an open-face one.
- Budget the update rate if the design uses more than one sensor: the ≥60 ms cycle multiplies across units unless triggers are staggered, and cross-talk between neighboring sensors is a wiring and timing problem, not a hardware defect.
These are the same modules referenced above — a good way to compare current options against the checklist:
- HC-SR04 Ultrasonic Sensor:This is a device that can use sound waves to measure the distance of an object. It measures distance by emitting a sound wave of a specific frequency and listening to the bounce of that sound wave. The distance between the sonar sensor and the object can be calculated by recording the time elapsed between the generation of the sound wave and the bounce of the sound wave
- Working Voltage: 5V DC;Quiescent current: less than 2mA
- Ranging Distance:2cm - 450 cm;High precision: 0.3 cm
- Effectual Angle: <15°
- Test mode :Test distance = ((Duration of high level)*(Sonic :340m/s))/2
- NON-CONTACT DISTANCE SENSING: Add object detection to robot navigation, parking-distance prototypes, automatic lids, counters and interactive projects; each HC-SR04 uses a 40 kHz ultrasonic burst and echo timing to estimate distance
- 5-PACK FOR REPEATABLE PROTOTYPING: Use multiple HC-SR04 modules across builds, compare sensor positions or keep spares for testing and replacement; each module integrates an ultrasonic transmitter, receiver and control circuit
- 5 V MODULE WITH 3-450 CM RANGE: Connect VCC, Trig, Echo and GND, use a 10 µs trigger pulse and measure Echo duration; resolution is 0.3 cm with an effective angle under 15°, while the controller board and external power source are not included
- PROTECT 3.3 V GPIO: The HC-SR04 operates from 5 V and its Echo output is 5 V, so use a voltage divider or suitable level shifting with 3.3 V inputs; keep the module dry and use it for prototyping rather than calibrated measurement
- FOR ROBOTICS & STEM PROJECTS: Suitable for distance measurement, object detection, automatic lids, parking alerts, robot navigation and other hands-on electronics builds
- EPLZON HC-SR04 Ultrasonic ranging transducer sensor
- Test mode: Use IO to trigger high-level signals. (Not less than 10us), the module automatically sends 8 40kHz and detects whether there is a pulse signal return.
- Detection area: 0.78~196 in/(2cm~500cm); high precision: up to 0.12 inch/(0.3 cm), effective angle: less than 15°; Trigger input pulse width: 10uS
- Power supply: 5V DC; Quiescent current: less than 2mA;Dimension: 1.77 x 0.78 x 0.59 inches/45mm x 20mm x 15mm(length*width*height)
- Test distance=((high level duration)*(sound wave: 340m/s))/2
Frequently asked questions about ultrasonic sensors
What does an ultrasonic sensor do?
It detects the presence and distance of an object by sending out a short burst of sound above human hearing — typically 40 kHz in low-cost modules — and timing how long the echo takes to come back. The elapsed time, combined with the speed of sound, converts directly into a distance reading.
Why did Tesla stop using ultrasonic sensors?
Tesla announced in October 2022 that it was removing ultrasonic sensors from Model 3 and Model Y (with Model S and Model X following in 2023), replacing the short-range detection they provided for auto-park and collision warnings with its camera-based Tesla Vision system. Tesla said the vision-based approach gave it longer-range visibility and a better ability to differentiate between objects than the ultrasonic sensors did — though several driver-assist features had to be temporarily disabled until the camera-based replacements caught up.
What are the key differences between an IR sensor and an ultrasonic sensor?
An ultrasonic sensor times a sound echo, so it works regardless of a target's color or transparency, but it struggles with soft, absorbent, or sharply angled surfaces that scatter or swallow the sound. An infrared distance sensor instead reflects or triangulates light, which reacts to a target's color and reflectivity and can be thrown off by strong ambient light such as direct sunlight, but isn't affected by soft or sound-absorbing materials. Neither is universally better — the right choice depends on the target material and the lighting or acoustic environment.
How far can an ultrasonic sensor detect?
It depends entirely on the module. The widely used HC-SR04 hobbyist module is rated for 2 cm to 400 cm by its manufacturer's datasheet. Purpose-built industrial ultrasonic sensors, designed for tank level gauging or large-object detection, use bigger transducers and more power to reach considerably farther — but the exact figure always comes down to that specific product's own published range, not a property of "ultrasonic" sensing in general.
How do you connect an HC-SR04 to a microcontroller?
Per the manufacturer's datasheet, the module needs four connections: 5V, ground, a trigger input, and an echo output. A microcontroller sends a high pulse of at least 10 microseconds to the trigger pin, then measures how long the echo pin stays high afterward. Dividing that time in microseconds by 58 gives the distance in centimeters directly, per the datasheet's own published shortcut.
For the bigger picture on how a sensor like this fits alongside radar, LiDAR, and inertial sensors in a single perception system, start with our pillar guide, What Is Sensor Fusion? A Complete Guide, or see how it compares to underwater and airborne ranging in Sonar vs Radar.
Last update 2026-10-03. Price and product availability may change.
Recommended: