HC-SR04 always shows 0 or a huge number
- HC-SR04
Why it happens
- TRIG and ECHO are swapped.
- Nothing is in range, or the object is soft or slanted.
- The sensor isn't getting 5 V.
How to fix it
- Match TRIG and ECHO to the pin numbers in the code.
- Point it at a flat wall 20 to 100 cm away.
- Connect VCC to 5V, not 3.3V, on an Uno.
- Stay beyond 2 cm: nearer than that it can't hear.
- Add
delay(60);between pings.
It worked if: Move a book nearer and farther: the number follows.
Tutorials where it can happen
- HC-SR04 Ultrasonic Sensor with Arduino Uno
- Colour Picker RGB LED with Arduino
- Distance Measurement and Stepper Motor Control with LCD Output
- Liquid Level Detection and Pump Control
- Object Tracking and Following System with LCD Feedback
- Obstacle Avoiding Robot Car with Arduino and LCD
10 more
- Obstacle-Avoiding Robot Arm with Arduino and LCD
- Smart Mailbox with Arduino, Ultrasonic Sensor and Servo
- Smart Pet Door with Arduino, Ultrasonic Sensor and Servo
- Smart Trash Can with Arduino: Lid Opens by Itself
- Ultrasonic Parking Sensor with LCD Display using Arduino
- Ultrasonic Sensor and Servo Motor with Arduino Uno
- Vehicle Parking Space Occupancy Detection with LCD Feedback
- Vehicle Speed Measurement and LCD Output Using Arduino
- Water Level Monitoring and Fish Tank Pump Control with Arduino
- Water Level Monitoring and Solar Water Heater Control
From how the part works. Explained from how the part works; not tried on a real circuit for this page.
Didn't help? Search another error or ask us.

