HC-SR04 ultrasonic sensor: range, accuracy and failure modes

A 15-degree cone, a 10-microsecond trigger and a lot of false confidence. How to read the echo correctly and what soft surfaces do to it.

By Jignesh Panchal · Sources, testing and AI policy

  • India price₹70–₹150
  • TypeSensors
  • LevelBeginner
  • ReviewedOct 2026
HC-SR04 ultrasonic sensor with jumper wires on a breadboard

The HC-SR04 measures a 15-degree cone, not a point, and its useful range is closer to 3–250 cm than the 2–400 cm on the listing. It is the right first distance sensor for a ₹1,000 robot. It is the wrong sensor for a soft curtain, a glass door or a robot that needs millimetre accuracy.

Key specifications

Operating voltage5 V
Currentabout 15 mA
Range2–400 cm claimed, 3–250 cm realistic
Beam angleabout 15 degrees
Trigger pulse10 microseconds
Echopulse width proportional to distance
Accuracyabout 3 mm at close range
Update rateabout 50 ms per reading

Substitute: VL53L0X time-of-flight for short range and soft targets, or JSN-SR04T for a waterproof probe.

How it measures

The module has a transmitter and a receiver. Pull TRIG high for 10 microseconds, and the board fires a burst of ultrasonic pulses. ECHO goes high until the echo returns, and the width of that pulse is proportional to the round trip. The usual conversion is distance in centimetres = echo time in microseconds ÷ 58, or distance in inches = time ÷ 148. The 58 comes from the speed of sound at room temperature; cold air changes it by roughly 0.6 m/s per degree Celsius, which is a few millimetres over two metres.

The sensor cannot tell you where inside the cone the reflection came from. A chair leg at 40 cm and a wall at 90 cm can produce readings that jump between the two, depending on which surface returns more energy. That is why a single reading is not enough for a robot; take several and use the median.

Wiring and logic levels

  • VCC to 5 V. The module is not a 3.3 V device; it may work below 5 V but the range and accuracy drop.
  • GND to the common ground.
  • TRIG to any digital output. A 10 µs pulse starts a measurement.
  • ECHO to a digital input. The pulse is 5 V, so an ESP32 or other 3.3 V board needs a divider (for example 1 kΩ and 2 kΩ) or a level shifter.

Never connect the 5 V echo directly to a 3.3 V GPIO and hope. Some boards tolerate it briefly; the datasheet does not. A two-resistor divider costs a few rupees and removes the risk.

A reading you can trust

Trigger low for 2 µs, then high for 10 µs, then read the echo with a timeout. A timeout matters: if no echo returns, pulseIn() will otherwise wait for its default period and stall your control loop. At 58 µs per centimetre, 30,000 µs corresponds to about 5 metres, which is a sensible upper bound. Discard zero readings, take three samples spaced by at least 20 ms, and use the median rather than the mean. The sensor needs roughly 50 ms between measurements; hammering it faster produces echoes from the previous burst.

On a moving robot, mount the sensor at bumper height and keep the transducers clear of the chassis. Recessing it in a tube creates ringing that the receiver hears as a close object. Two HC-SR04 sensors facing the same direction will interfere; trigger them alternately or separate them by more than a metre if they must run together.

Failure modes and what they look like

ReadingLikely causeCheck
Always 0No echo, wrong pin, no common ground, or trigger pulse too short.Scope or serial-print the echo width; verify TRIG with an LED test.
Stuck at maximumObject is out of range, too soft, or angled away.Test against a flat wall at 30–100 cm.
Random jumpsCross-talk, supply noise, or a reflective floor.Increase the interval, add a capacitor, mount higher.
Consistently shortSoft target, narrow object, or the chassis is in the cone.Move the sensor forward; test with a hard board.
Works on USB, fails on batterySupply sag or a missing ground.Measure 5 V at the module while measuring.

When the HC-SR04 is the wrong choice

  • Soft or angled targets: curtains, foam, clothing and sloped surfaces absorb or deflect the pulse. Use a time-of-flight sensor or a short-range IR sensor.
  • Outdoors in wind or rain: the air path is disturbed and the module is not sealed. Use a waterproof JSN-SR04T probe, accepting its slower response.
  • Very close work: below about 3 cm the sensor is in its blind zone. A VL53L0X time-of-flight sensor is better for 3–120 cm.
  • Precision mapping: the cone is wide and the reading is an average of whatever it hits. Use a scanning lidar or a camera if you need geometry.

Common questions

Why does the HC-SR04 read 0 cm?

No echo returned within the timeout, or the echo pin is not connected to the right input. Check the common ground, the trigger pulse and the timeout in your code.

Can I connect the echo pin directly to an ESP32?

No. The echo is a 5 V signal and the ESP32 is a 3.3 V device. Use a resistor divider or a level shifter.

What is the real maximum range?

About 250 cm against a flat, hard target in still air. The 400 cm figure assumes ideal conditions that a classroom robot rarely has.

How often can I take a reading?

About every 50 ms. Faster reads can pick up the previous burst and produce false close readings.

Related: obstacle avoiding robot, ESP32 robot car, Arduino Uno guide, where to buy parts.

Keep reading

Sources and further reading

Documents used to check the numbers on this page:

Last reviewed: October 2026. Specifications checked against common HC-SR04 datasheets. Prices are Indian retail ranges.

Where to buy in India

These open a store search. Compare seller, price and reviews before you order.

Free: the final-year project pack

A shortlist with BOMs, a report outline that matches the usual chapter scheme, a costing sheet and 40 viva questions. Built for the February–April submission season.

The Build Note

One short email when something is worth your bench time.

A new build sheet, a part price that moved, or a mistake worth avoiding. No daily drip, no recycled news.

One short email when a build or a price is worth your time. Unsubscribe in one click.