
HC-SR04 Ultrasonic Distance Sensor Module – 2cm to 400cm for Arduino & ESP32
The HC-SR04 Ultrasonic Distance Sensor is the most popular non-contact distance measurement module in the maker community. Using ultrasonic sound pulses, it accurately measures distances from 2cm to 400cm with a resolution of approximately 3mm — all with a simple 4-pin interface.
Key Specifications
- Operating Voltage: 5V DC
- Measuring Range: 2cm – 400cm
- Accuracy: ±3mm
- Measuring Angle: 15°
- Trigger Input: 10µs TTL pulse
- Echo Output: TTL pulse proportional to distance
- Operating Frequency: 40 kHz
- Connector: 4-pin (VCC, Trig, Echo, GND)
Compatibility & Use Cases
The HC-SR04 is directly compatible with Arduino, ESP32, NodeMCU, and Raspberry Pi via standard GPIO pins. Common applications include:
- Obstacle detection and avoidance in robotics
- Parking sensor and proximity alert systems
- Liquid level measurement in tanks
- People counter and occupancy detection for IoT
- STEM and educational distance measurement projects
Use the NewPing or HCSR04 Arduino library for clean, interrupt-driven distance readings without blocking delays.
Frequently Asked Questions
Can I use the HC-SR04 with a 3.3V ESP32 or Raspberry Pi?
Yes. Power the sensor from 5V and trigger it from your 3.3V GPIO. The Echo pin outputs 5V, so add a simple resistor voltage divider on the Echo line before connecting it to a 3.3V input pin.
Which library should I use with Arduino?
The NewPing library is the easiest option and handles timing for you. You can also read the sensor with the built-in pulseIn() function and no library at all.
What surfaces can it measure reliably?
Hard, flat surfaces like walls, boxes and water give the most accurate readings. Soft or sound-absorbing materials such as cloth and foam, and objects at a steep angle, can return weak or unstable readings.
What is the minimum distance it can measure?
The reliable range starts at about 2cm. Objects closer than 2cm sit in the sensor's blind zone and give erratic results.
Order now from Xsortex HUB and get fast delivery across India.
- Choosing a selection results in a full page refresh.
- Opens in a new window.
