What it is
The ShillehTek HC-SR04 Ultrasonic Distance Sensor Module 4-Pin helps Arduino and Raspberry Pi projects measure distance using echolocation—sending ultrasonic pulses and timing the returning echo. It’s a reliable, low-cost choice for robots and obstacle detection, and it performs well in both darkness and bright sunlight where IR sensors can struggle.
Pins
- Trigger (input): Starts a measurement by initiating the ultrasonic pulse.
- Echo (output): Returns a pulse whose timing is used to calculate distance.
Because this is a 4-pin module, power and ground pins are also present—refer to the silkscreen labels on your board and the listing photos for exact pin names and order.
Technical Specifications
| Parameter | Value |
|---|---|
| Sensor type | Ultrasonic distance (echolocation) |
| Distance measurement range | 2 cm to 400 cm (about 13 ft) |
| Accuracy / repeatability | Accuracy can be as fine as 3 mm (application-dependent) |
| Interface | Separate Trigger (input) and Echo (output) signals |
| Platform compatibility | Arduino and Raspberry Pi |
| Library support | Works with common libraries (e.g., NewPing) for filtering/control |
Frequently Asked Questions
How do I wire the HC-SR04 to an Arduino?
Connect power/ground according to the module silkscreen, then connect Trigger to a digital output pin and Echo to a digital input pin. Many Arduino tutorials and the NewPing library examples show the typical hookup and timing method.
What is the distance range of the ShillehTek HC-SR04 ultrasonic sensor?
The stated measurement range is 2 cm to 400 cm (about 13 feet). Real-world results depend on target surface, angle, and environment.
Does the HC-SR04 work in bright sunlight or in the dark?
Yes. Because it uses sound instead of light, it typically performs well in darkness and bright sunlight where IR distance sensors often fail.
Can the HC-SR04 detect glass, mirrors, or dark surfaces?
It can work on glass, mirrors, and dark surfaces since it relies on ultrasonic echoes rather than reflected IR light. Best results come from aiming the sensor squarely at the target and testing in your setup.
Is there a recommended library for HC-SR04 projects?
Common Arduino libraries such as NewPing are widely used for HC-SR04 modules and can simplify triggering, timing, and basic filtering. Choose a library that matches your board and timing needs.