HC-SR04 Ultrasonic Sensor: Reviewed and Tested

ELEGOO HC-SR04 ultrasonic distance sensor

The HC-SR04 shows up in more Arduino robotics tutorials than almost any other single sensor — obstacle-avoiding robots, parking sensors, water-level gauges, theremin projects. We put a five-pack through actual distance tests to see whether the hype holds up or whether you’re better off spending more on something newer.

How It Actually Works

It’s a time-of-flight sensor, and the whole trick is measuring an echo instead of measuring distance directly. Send a 40kHz ultrasonic pulse out the “Trig” pin; it travels through the air, bounces off whatever’s in front of it, and comes back to the sensor’s receiver, which flips the “Echo” pin HIGH for exactly as long as that round trip took. Multiply that time by the speed of sound (roughly 343 meters per second at room temperature) and divide by two — since the pulse traveled the distance twice, out and back — and you have the distance to the object. The Arduino library handles that math for you, but knowing it’s happening explains why temperature actually affects accuracy slightly (the speed of sound changes with air temperature) and why the sensor is fundamentally guessing based on an echo, not directly sensing distance the way, say, a tape measure does.

Four pins total (VCC, Trig, Echo, GND), 5V logic, and it works with a two-line library call once wired up. There’s no I2C or SPI complexity here, which is a real part of the appeal — see our 5V vs. 3.3V explainer if you’re pairing this sensor with a 3.3V board like an ESP32, since the HC-SR04 is a 5V-only part and needs a level converter in that case.

Accuracy: Good in the Middle, Rough at the Edges

Across five units, readings between 20cm and 300cm were consistently accurate to within about a centimeter against a tape measure — genuinely solid for the price. Below about 5cm the readings got noisy and occasionally returned nonsense values, which tracks with how the sensor works: at very short range, the outgoing pulse and the returning echo can overlap in time, confusing the timing measurement the whole calculation depends on. Soft or angled surfaces (a couch cushion, a wall hit at a sharp angle) scattered the echo and produced unreliable results too — an angled surface reflects sound away from the receiver rather than back at it, the same way a mirror reflects light away from you unless you’re looking at it head-on. Flat, hard, roughly perpendicular surfaces are where this sensor is happiest.

Where It Falls Short

It’s a single-point sensor — no field-of-view detail, so a small obstacle at the edge of its cone can be missed entirely. It’s also noticeably slower to poll than modern time-of-flight sensors like the VL53L0X (which use infrared light instead of sound, and can be read many times faster) if your project needs rapid updates. For a hobby robot doing basic obstacle avoidance at walking pace, none of this matters. For anything more precise, it’s a starting point, not an endpoint.

This post contains affiliate links. If you buy through them, this site earns a commission at no extra cost to you.

ELEGOO HC-SR04 Ultrasonic Sensor
ELEGOO HC-SR04 Ultrasonic Sensor (5-Pack)

Reliable, cheap, and well-documented. The default choice for a first obstacle-avoidance or distance-sensing project.

Check Price on Amazon →

Verdict

Buy it. At this price, with a five-pack giving you spares for when you inevitably fry one, there’s no real reason to start anywhere else for distance sensing. Upgrade to a time-of-flight sensor later only if a specific project actually demands the extra precision.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top