HC-SR04 Ultrasonic Distance Measuring Sensor Module — 2cm to 400cm Range, 3mm Accuracy, Arduino Compatible
HC-SR04 Ultrasonic Distance Measuring Sensor Module — 2cm to 400cm Range, 3mm Accuracy, Arduino Compatible
Couldn't load pickup availability
Measure distance without touching anything — the HC-SR04 Ultrasonic Distance Sensor uses sonar to measure the distance to an object from 2cm to 400cm (1 inch to 13 feet) with up to 3mm accuracy. It sends out a burst of 40 KHz ultrasonic sound, listens for the echo, and outputs a timed pulse that your microcontroller converts to distance with a single line of math. Works in complete darkness, isn't fooled by color or transparency, and needs just four wires — no libraries required.
Whether you're building an obstacle-avoiding robot, a parking sensor, a liquid level monitor, or a contactless ruler, the HC-SR04 is the go-to sensor for the job.
⚡ Key Features
- Non-contact distance measurement: 2cm to 400cm (1" to 13 ft) — no physical contact with the target needed.
- High accuracy: Up to 3mm resolution for precise measurements.
- ~15° beam angle: Focused enough to avoid false readings from nearby objects, wide enough for practical use.
- Works in any lighting: Ultrasonic — not affected by sunlight, darkness, or object color/transparency. Unlike IR sensors, it works on black and transparent objects.
- Simple 4-pin interface: VCC, Trig, Echo, GND. Send a 10µs trigger pulse, read the echo duration, calculate distance. No I2C, SPI, or libraries required.
- Low power: Less than 2mA quiescent, ~15mA during measurement — suitable for battery-powered projects.
- Fast: Up to 20 measurements per second (~50ms per cycle).
- Compact: 45mm × 20mm × 15mm — the two ultrasonic transducers give it a distinctive "eyes" appearance.
🔧 How It Works
- Trigger: Send a 10-microsecond HIGH pulse to the Trig pin.
- Transmit: The sensor emits 8 ultrasonic pulses at 40 KHz.
- Echo: The sound bounces off the nearest object and returns to the receiver.
- Measure: The Echo pin goes HIGH for a duration equal to the round-trip time.
- Calculate: Distance (cm) = Echo time (µs) ÷ 58.2
That's it. One trigger, one echo, one division. No calibration, no warm-up, no configuration.
💡 Quick Formula: Distance (cm) = pulseIn(echoPin, HIGH) / 58.2 | Distance (inches) = pulseIn(echoPin, HIGH) / 148
📌 Pinout
| Pin | Label | Connect To | Function |
|---|---|---|---|
| 1 | VCC | 5V | Power supply — must be 5V DC |
| 2 | Trig | Digital pin (e.g., D9) | Trigger input — send 10µs pulse to start measurement |
| 3 | Echo | Digital pin (e.g., D10) | Echo output — HIGH duration = round-trip time |
| 4 | GND | GND | Ground |
⚠️ 3.3V Systems (ESP32, Raspberry Pi): The Echo pin outputs 5V. You must use a voltage divider (1KΩ + 2KΩ) on the Echo line to protect 3.3V GPIO pins. The Trig pin accepts 3.3V input — no divider needed on Trig. Full wiring details in our User Guide.
🎯 Perfect For
- Obstacle-avoiding robots — detect walls and objects, navigate autonomously
- Parking sensors — mount in a garage to show distance to the wall with LEDs or a buzzer
- Liquid level monitoring — mount above a tank, measure distance to the water surface
- Contactless ruler / tape measure — point at a wall, read distance on an LCD/OLED display
- People counter — detect people passing through a doorway
- Automatic hand sanitizer / soap dispenser — detect hand proximity and trigger a pump
- Smart trash can — auto-open lid when a hand approaches
- Musical instrument (theremin-style) — map distance to tone frequency
- Security / intrusion detection — alert when distance changes in a monitored area
- STEM education — teach speed of sound, sonar, and sensor integration
📐 Specifications
- Operating voltage: 5V DC
- Operating current: ~15mA (during measurement)
- Quiescent current: <2mA
- Ultrasonic frequency: 40 KHz
- Measuring range: 2cm – 400cm (1" – 13 ft)
- Accuracy: Up to 3mm
- Measuring angle: ~15° cone
- Trigger input: 10µs TTL pulse
- Echo output: 5V TTL pulse (duration = round-trip time)
- Measurement cycle: ~50ms minimum (20 Hz max rate)
- Dimensions: 45mm × 20mm × 15mm (1.77" × 0.79" × 0.59")
- Weight: ~11g
🔌 Compatible With
- Arduino Uno, Mega, Nano, Leonardo — direct connection, no additional components
- ESP32 / ESP8266 — requires voltage divider on Echo pin (5V → 3.3V)
- Raspberry Pi — requires voltage divider on Echo pin (5V → 3.3V)
- STM32, AVR, PIC — any microcontroller with digital I/O (voltage divider for 3.3V systems)
- NewPing library supported for simplified code and median filtering
📦 Package Contents
- 1 × HC-SR04 Ultrasonic Distance Measuring Sensor Module
Arduino, jumper wires, breadboard, and USB cable are not included.
📄 Documentation & Resources
Share
