HS-SR04 Ultrasonic Distance Sensor - HC-SR04 Compatible Ranging Module for Arduino and Raspberry Pi The HS-SR04 ultrasonic distance sensor is an HC-SR04-compatible ranging module for robot obstacle avoidance, object distance measurement, liquid-level experiments, and security or parking demos. It keeps the familiar trigger/echo workflow while the current listing describes it as an optimized HC-SR04-style design with stable performance and a small blind zone. The product page lists a detection range of 3cm to 4m and support for Arduino, Raspberry Pi, and other microcontrollers. It works well with the ELAB Nano V3, Raspberry Pi Pico W, and wiring accessories such as the MB 102 Breadboard Kit. Use the trigger pin to start a measurement and the echo pin to measure return time. As with any ultrasonic sensor, target angle, surface material, temperature, and acoustic noise can affect readings. Technical Specifications Parameter Value SKU HS-SR04 Product Type HC-SR04 compatible ultrasonic distance sensor Detection Range 3cm-4m per current listing Pins G, V, T, E Trigger Pin T Echo Pin E Supply Voltage 3.3V / 5V per current listing Connection 2.54mm pin header Mounting Double-screw mounting Applications Robot avoidance, ranging, liquid level, security demos Board Layout & Label Guide G - Power ground. V - Positive supply. T - Trigger signal input. E - Echo signal output. Transmitter - Sends ultrasonic pulse. Receiver - Detects reflected echo. Mounting Holes - Secure the module to the robot or fixture. Clearance Note - Keep the front area free from brackets or wires. 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 HS-SR04 Ultrasonic Distance Sensor Module FAQ Q: Is this compatible with HC-SR04?A: Yes, the current page describes it as HC-SR04 compatible. Q: What is the listed range?A: The listing specifies 3cm to 4m. Q: Which pins does it use?A: G, V, T, and E for ground, power, trigger, and echo. Q: Can I use it with Raspberry Pi?A: Yes, but protect 3.3V inputs if Echo is 5V. Q: Can it detect soft objects?A: Soft angled objects may produce weak echoes. Q: Can it measure liquid level?A: Yes, in simple non-contact level demos. Q: Why do readings time out?A: No echo may be returned within the timeout window. Q: How do I improve stability?A: Average multiple readings and mount it firmly.