HC-SR04 Ultrasonic Sensor - 2cm to 450cm Distance Measurement Module for Arduino Projects The HC-SR04 ultrasonic sensor is a 5V distance-measurement module for obstacle detection, ranging experiments, liquid-level demos, and robot navigation. It sends an ultrasonic pulse from the trigger pin, listens for the reflected echo, and lets software calculate distance from the echo pulse width. This module is easy to prototype with the ELAB Nano V3, an UNO R3 Prototype Expansion Board, or a quick test rig built on the MB 102 Breadboard Kit. It is a good choice when a low-cost non-contact range sensor is enough and the target surface reflects sound well. The current listing specifies 5V operation, less than 2mA quiescent current, 2cm to 450cm detection range, up to 0.3cm precision, and a sensing angle not more than 15 degrees. Use level shifting for the echo pin when connecting to 3.3V-only controllers. Technical Specifications Parameter Value SKU HC-SR04 Product Type Ultrasonic distance sensor Working Voltage 5V DC Quiescent Current Less than 2mA Detection Range 2cm-450cm Precision Up to 0.3cm Sensing Angle Not more than 15 degrees Output Level 3.3V-5V high level, 0V low level Interface VCC, Trig, Echo, GND Applications Robots, obstacle detection, ranging, liquid-level demos Board Layout & Label Guide VCC - 5V power input. Trig - Trigger input; send a 10us pulse to start measurement. Echo - Echo pulse output; pulse width represents distance. GND - Common ground with controller. Ultrasonic Transmitter - Sends the measurement pulse. Ultrasonic Receiver - Receives the reflected echo. Mounting Note - Keep the sensor face clear and perpendicular to the target. Logic Note - Use level shifting for 3.3V-only controller inputs. Application Scenarios 1. Arduino Distance Readout Measure echo pulse width and convert it to distance in centimeters. const int trigPin = 9; const int echoPin = 10; void setup() { Serial.begin(115200); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); } void loop() { digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); long duration = pulseIn(echoPin, HIGH, 30000); float cm = duration * 0.0343 / 2.0; Serial.println(cm); delay(200); } 2. Obstacle Alarm Trigger an LED when an object is closer than a selected threshold. const int trigPin = 9; const int echoPin = 10; const int ledPin = 13; float readCm() { digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); return pulseIn(echoPin, HIGH, 30000) * 0.0343 / 2.0; } void setup() { pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode(ledPin, OUTPUT); } void loop() { digitalWrite(ledPin, readCm() < 20.0 ? HIGH : LOW); delay(100); } 3. MicroPython Ultrasonic Check Read an ultrasonic module from a Pico-style board. from machine import Pin, time_pulse_us import time trig = Pin(3, Pin.OUT) echo = Pin(2, Pin.IN) while True: trig.low() time.sleep_us(2) trig.high() time.sleep_us(10) trig.low() duration = time_pulse_us(echo, 1, 30000) print(duration * 0.0343 / 2) time.sleep(0.2) Packing List 1 x HC-SR04 Ultrasonic Sensor Module FAQ Q: What does it measure?A: It measures distance by timing ultrasonic echo return. Q: What voltage does it need?A: The listing specifies 5V DC. Q: Can it work with 3.3V boards?A: Use level shifting for Echo when the host is not 5V tolerant. Q: What is the range?A: The current listing specifies 2cm to 450cm. Q: Why are readings unstable?A: Soft targets, angled surfaces, airflow, and noise can affect echoes. Q: Can it measure water level?A: Yes, for non-contact tank or container demos when mounted above the surface. Q: Does it work on cloth?A: Soft materials may absorb sound and reduce reliability. Q: How do I improve accuracy?A: Average readings and mount the sensor firmly facing the target.