HC-SR04 Ultrasonic Sensor
Popular ultrasonic distance sensor for robots, bins and water-level demos.
AI Ready Overview
Quick Summary
HC-SR04 is a distance sensor commonly used in FYP and embedded projects. It is best for obstacle avoidance and smart bin fill level, with wiring and testing planned around Arduino, ESP32, STM32.
Difficulty
Beginner
Time Required
1-3 days for basic wiring and sample code; 1 week if used inside a complete FYP prototype
Cost
RM3-RM10 module range in Malaysia; full project cost depends on scope.
Components
HC-SR04, Arduino, ESP32, STM32
Overview
What is HC-SR04?
HC-SR04 measures distance using ultrasonic pulses. It is cheap and common in obstacle avoidance, smart bin, blind stick and level detection prototypes.
Engineering Reference
Quick Specs
| Operating Voltage | 5V |
|---|---|
| Range | About 2cm to 400cm |
| Interface | Trigger and echo pins |
| Best For | Distance and level demos |
Real Usage Notes
Suitable / Not Suitable
Suitable for
- ✓ Obstacle avoidance
- ✓ Smart bin fill level
- ✓ Water tank level demo
- ✓ Blind stick prototype
Not suitable for
- ✕ Soft/angled surfaces
- ✕ Outdoor rain exposure
- ✕ High-precision measurement
Build Planning
Difficulty
HC-SR04 is rated Beginner. Plan around 1-3 days for basic wiring and sample code; 1 week if used inside a complete fyp prototypedepending on wiring, libraries, calibration, dashboard/app integration and testing evidence.
Build Planning
Time Required
1-3 days for basic wiring and sample code; 1 week if used inside a complete FYP prototype
Malaysia Price Guidance
Cost
Typical module price range: RM3-RM10. This is component guidance only; a complete FYP cost depends on controller, sensors, casing, display, app/dashboard, documentation and timeline.
Connections
Pinout
VCC
5V power input.
TRIG
Trigger pulse input.
ECHO
Echo pulse output. Level shift for 3.3V boards.
GND
Ground connection.
Platform Notes
Wiring Guides
HC-SR04 with Arduino
Connect trigger and echo to digital pins.
| VCC | 5V |
|---|---|
| TRIG | D9 |
| ECHO | D10 |
| GND | GND |
Fix Common Problems
Troubleshooting
Troubleshooting
Common Mistakes
FYP Ideas Using HC-SR04
Related Projects
Compare Options
Alternative Components
Student Questions
FAQ
Can HC-SR04 work with ESP32?
Yes, but the echo pin is 5V on many modules, so use voltage scaling for ESP32 input.
