HC-SR04 Ultrasonic Sensor distance measuring module 4pin 3-5V GPIO

SKU: FA3006-1-2
Module Model

HC-SR04

Operating Voltage

3V – 5V DC

Ultrasonic Frequency

40kHz

Detection Range

2cm – 400cm

Measurement Accuracy

Up to ±3mm

Interface

GPIO (Trigger/Echo)

Pin Count

4 pins (VCC, GND, Trig, Echo)

Module Dimensions

Approx. 45mm × 20mm × 15mm

The HC-SR04 Ultrasonic Sensor Distance Measuring Module is a compact, low-cost ranging module that uses ultrasonic waves to measure distance from 2cm to 400cm with an accuracy of up to ±3mm. It is the most widely used ultrasonic sensor in the maker and robotics communities, known for its reliability, simplicity, and excellent value. This version operates from 3V to 5V DC and uses the standard GPIO (trigger/echo) interface.

At the heart of the module is an ultrasonic transmitter and receiver pair that works on the principle of time-of-flight measurement. The transmitter emits a 40kHz ultrasonic burst, which travels through the air, reflects off an object, and returns to the receiver. The module measures the time between transmission and reception, then calculates the distance using the speed of sound.

The module features a 4-pin interface (VCC, GND, Trig, Echo) for easy connection to microcontrollers. The Trig pin accepts a 10µs trigger pulse to initiate a measurement, and the Echo pin outputs a pulse whose duration is proportional to the measured distance. The distance is calculated using the formula: Distance (cm) = Echo pulse duration (µs) / 58.

The wide operating voltage range of 3V to 5V makes the module compatible with both 3.3V and 5V microcontrollers, including Arduino, ESP32, ESP8266, STM32, and Raspberry Pi. The compact form factor with mounting holes allows easy integration into robot chassis, sensor arrays, and custom enclosures.

The module is widely used in robotics, obstacle avoidance, liquid level sensing, parking sensors, human detection, distance measurement, and DIY automation projects. It is also popular in educational projects for teaching ultrasonic ranging, time-of-flight measurement, and sensor integration.

Important Note: The HC-SR04 uses ultrasonic waves, which are affected by temperature, humidity, and air pressure. For high-precision applications, consider temperature compensation. The module requires a minimum delay of 60ms between measurements to avoid echo interference. Objects with soft, angled, or irregular surfaces may not reflect sound waves effectively, reducing detection reliability. The module is not waterproof — do not immerse in water or operate in wet environments without protection.

Whether you are building a robot with obstacle avoidance, a parking sensor, or a liquid level monitoring system, the HC-SR04 Ultrasonic Sensor Module provides a reliable, proven solution. It is suitable for individual makers, students, and businesses purchasing in bulk for product development or educational programs.

Features

  • GPIO (trigger/echo) interface — Simple, widely supported communication

  • Wide voltage range — 3V to 5V DC operation

  • Reliable ranging — Measures 2cm to 400cm with ±3mm accuracy

  • 40kHz ultrasonic frequency — Standard frequency for consistent performance

  • 4-pin interface — VCC, GND, Trig, Echo

  • Compact form factor — With mounting holes for easy integration

  • Low power consumption — Suitable for battery-powered applications

  • Wide application range — Robotics, obstacle avoidance, liquid level, parking sensors

  • Proven technology — Most widely used ultrasonic sensor with extensive documentation

  • Cost-effective — Affordable solution for distance measurement

Technical Specifications 

# Parameter Specification
1 Module Model HC-SR04
2 Operating Voltage 3V – 5V DC
3 Ultrasonic Frequency 40kHz
4 Detection Range 2cm – 400cm
5 Measurement Accuracy Up to ±3mm
6 Interface GPIO (Trigger/Echo)
7 Pin Count 4 pins (VCC, GND, Trig, Echo)
8 Module Dimensions Approx. 45mm × 20mm × 15mm

Usage

Getting Started

  1. Connect power — Supply 3V to 5V DC to the VCC pin and GND to ground.

  2. Connect trigger and echo — Connect the Trig pin to a digital output on your microcontroller and the Echo pin to a digital input.

  3. Send a trigger pulse — Set the Trig pin HIGH for 10µs to initiate a measurement.

  4. Read the echo pulse — Measure the duration of the HIGH pulse on the Echo pin. The distance is calculated as: Distance (cm) = Echo pulse duration (µs) / 58.

  5. Add a delay — Wait at least 60ms between measurements to avoid echo interference.

Pin Connections

Module Pin Function
VCC Power (3V–5V)
GND Ground
Trig Trigger input (10µs pulse)
Echo Echo output (pulse duration proportional to distance)

Example Arduino Code

cpp
const int trigPin = 9;
const int echoPin = 10;

void setup() {
  Serial.begin(9600);
  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);
  int distance = duration / 58;

  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println(" cm");
  delay(100);
}

Typical Applications

  • Robotics — Obstacle avoidance and navigation

  • Liquid level sensing — Measure water levels in tanks and containers

  • Parking sensors — Vehicle proximity detection

  • Human detection — Presence sensing for automation

  • Distance measurement — General-purpose ranging

  • DIY automation projects — Custom distance-based control

Notes for Business Buyers

  • Proven technology — HC-SR04 is the most widely used ultrasonic ranging module with extensive documentation and community support.

  • Wide voltage compatibility — Works with both 3.3V and 5V microcontrollers.

  • Cost-effective — Affordable solution for distance measurement in volume production.

  • Suitable for bulk purchasing — Ideal for robotics manufacturers, educational institutions, and product development.

Q: What is the HC-SR04 Ultrasonic Sensor Module used for?

It is a distance measuring module that uses ultrasonic waves to measure distance from 2cm to 400cm, used in robotics, obstacle avoidance, liquid level sensing, and parking sensors.

Q: What is the detection range and accuracy?

The detection range is 2cm to 400cm with an accuracy of up to ±3mm.

Q: What voltage does the module require?

It operates from 3V to 5V DC, making it compatible with both 3.3V and 5V microcontrollers.

Q: How do I calculate distance from the echo pulse?

Use the formula: Distance (cm) = Echo pulse duration (µs) / 58. For inches, divide by 148.

Q: What is the minimum delay between measurements?

Wait at least 60ms between measurements to avoid echo interference and ensure accurate readings.

Q: Does the module work with soft or angled surfaces?

Not reliably. Soft, angled, or irregular surfaces may not reflect sound waves effectively, reducing detection reliability.

Q: Is the module waterproof?

No. The HC-SR04 is not waterproof. Do not immerse it in water or operate it in wet environments without protection.

Q: Can I use this module with a 3.3V microcontroller?

Yes. The module operates from 3V to 5V DC, making it compatible with 3.3V and 5V systems.

Q: What is the trigger pulse width?

The trigger pulse should be 10µs long. Set the Trig pin HIGH for 10µs, then LOW to initiate a measurement.

Q: Can I purchase in bulk for a product development project?

Yes. This module is suitable for both individual users and business purchasing, including robotics manufacturers, educational institutions, and product development.