Electronics for IoT, Prototyping & DIY
HC-SR04 Ultrasonic Distance Measuring Sensor Module -- 2cm to 400cm Range, 3mm Accuracy, Arduino Compatible
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.
🔧 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
Pinout:
PinLabelConnect ToFunction1VCCArduino 5VPower supply -- must be 5V DC2TrigDigital pin (e.g., D9)Trigger input -- send 10µs pulse to start measurement3EchoDigital pin (e.g., D10)Echo output -- 5V HIGH duration = round-trip time4GNDArduino GNDGround⚡ 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, wide enough for practical use.
- Works in Any Lighting: Ultrasonic -- not affected by sunlight, darkness, or object color/transparency.
- Simple 4-Pin Interface: VCC, Trig, Echo, GND. No I2C, SPI, or libraries required.
- Low Power: Less than 2mA quiescent, ~15mA during measurement -- battery-friendly.
- Fast: Up to 20 measurements per second (~50ms per cycle).
- Compact: 45mm × 20mm × 15mm with distinctive dual-transducer \"eyes\" design.
📐 SpecificationsOperating Voltage5V DCOperating Current~15mA (during measurement)Quiescent Current<2mAUltrasonic Frequency40 KHzMeasuring Range2cm – 400cm (1\" – 13 ft)AccuracyUp to 3mmMeasuring Angle~15° coneTrigger Input10µs TTL pulseEcho Output5V TTL pulse (duration = round-trip time)Measurement Cycle~50ms minimum (20 Hz max rate)Dimensions45 × 20 × 15mm (1.77\" × 0.79\" × 0.59\")Weight~11g
📏 Quick Formula: Distance (cm) = pulseIn(echoPin, HIGH) / 58.2 | Distance (inches) = pulseIn(echoPin, HIGH) / 148
📦 What\'s in the Box
- 1x HC-SR04 Ultrasonic Distance Measuring Sensor Module
Arduino, jumper wires, breadboard, and USB cable are not included.
🛒 What You\'ll Need
- Microcontroller -- Arduino Uno/Mega/Nano, ESP32, Raspberry Pi, or any board with digital I/O
- 4 × jumper wires -- to connect VCC, Trig, Echo, and GND
- USB cable -- to program your Arduino and view serial output
- (For 3.3V systems only) 1KΩ + 2KΩ resistors for voltage divider on Echo pin
🔌 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
- NewPing library supported for simplified code and median filtering
⚠️ 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 on the Envistia Mall product support website.
🎯 Typical Applications
- Obstacle-avoiding robots -- detect walls and objects, navigate autonomously
- Parking sensors -- mount in a garage to show distance with LEDs or a buzzer
- Liquid level monitoring -- mount above a tank, measure distance to water surface
- Contactless ruler / tape measure -- point at a wall, read distance on a display
- People counter -- detect people passing through a doorway
- Automatic hand sanitizer / soap dispenser -- detect hand proximity, trigger 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
💡 Tip: Full documentation including Arduino code examples (basic, NewPing library, median filtering, proximity alert, temperature-compensated), ESP32/Pi voltage divider wiring, accuracy tips, and troubleshooting is available on the Envistia Mall product support website. Search for \"HC-SR04 User Guide\".
⚠️ Important Notes
- Requires 5V power. The HC-SR04 will not operate reliably at 3.3V. Always power from a 5V source.
- Echo pin outputs 5V. For ESP32, ESP8266, Raspberry Pi, and other 3.3V systems, you must use a voltage divider or level shifter on the Echo pin.
- Minimum range is 2cm. Objects closer than 2cm will return 0 or unreliable readings.
- Maximum practical range depends on target size and surface. 400cm is achievable with large, flat, hard surfaces. Small or soft objects: 100–200cm typical.
- Allow 50–60ms between measurements. Faster polling can cause echo interference and erratic readings.
- Soft materials (fabric, foam, fur, carpet) absorb ultrasonic pulses and may not reflect reliably.
- The 40 KHz frequency is inaudible to humans but may be audible to dogs, cats, and other animals.
- Not waterproof. For liquid level measurement, mount above the liquid, not submerged.
- If using multiple HC-SR04 sensors, trigger them sequentially (not simultaneously) to prevent cross-talk.
🏪 About Envistia Mall
Envistia Mall is a US-based electronics retailer specializing in development boards, sensors, modules, and components for makers, engineers, and educators. We ship from the United States with fast handling times. Product documentation and technical support are available at our dedicated support site.
📦 Fast Free US Shipping | 🔄 Hassle-Free Returns | 📧 Responsive Customer Support
Visit our store for more sensors (PIR motion, joystick, IR), Arduino-compatible boards, ESP32 modules, LEDs, jumper wires, and electronic components for your robotics and automation projects.
Featured Products
MQ-5 Methane LPG Natural Gas Propane Sensor Detector Module For Arduino US
$6.49
MQ-7 Carbon Monoxide CO Gas Sensor Detector Module For Arduino US
$6.89
3Pcs MQ-135 NH3 NOx Alcohol Benzene Smoke CO2 Sensor Detector Module For Arduino
$12.79
Capacitive Soil Moisture Sensor Analog 0-3V Output V1.2 for Arduino with Cable
$6.79
5Pcs TCRT5000L Infrared IR Optical Emitter / Sensor Photodiode Phototransistor
$5.69
MQ-135 NH3 NOx Alcohol Benzene Smoke CO2 Gas Sensor Detector Module For Arduino
$6.79
Microwave Doppler Radar Motion Detector Sensor RCWL-0516 Module Board
$6.39
KY-037 Microphone Audio Sound Detection Sensor Module
$6.49 Add suggested items to your listings - Check it out on 3Dsellers.com
· All Rights Reserved to My Store ·
listing template by 3Dsellers.com - Try for Free!
When you click on links to various merchants on this site and make a purchase, this can result in this site earning a commission. Affiliate programs and affiliations include, but are not limited to, the eBay Partner Network.