HC-SR04 Ultrasonic Distance Sensor Module

HC-SR04 Ultrasonic Distance Sensor Module

1 Pack
$3.89 NZD
Skip to product information

HC-SR04 Ultrasonic Distance Sensor Module

$3.89 NZD
Pack Size
Each unit:
Availability:
Rated 4.88/5 by 17 NZN customers Verified

Tax included. Shipping from $5.99 urban / $9.99 rural — free over $66.

Locally Stocked in Te Awamutu, Waikato
Same-day dispatch before 12:00PM
12 Month Warranty
American Express Apple Pay Google Pay Mastercard PayPal Shop Pay Union Pay Visa

30-day returns on faulty items · 12-month warranty

Checking free delivery progress...

Urban $66 Rural $88

HC-SR04 — Ultrasonic Distance Sensor Module

A popular 40 kHz ultrasonic ranging module capable of measuring distances from 2 cm to 450 cm with up to 3 mm precision. Sends a timed echo pulse and lets your microcontroller calculate distance using the speed of sound. Works directly with Arduino, ESP32, and Raspberry Pi GPIO pins with no extra components required.

2–450cm Detection Range
3mm Precision
40 kHz Ultrasonic Freq.
DC 5V Supply Voltage
  • 2 cm Blind-Zone Minimum
  • 450 cm Maximum Range
  • ±15° Sensing Angle
  • Arduino Compatible
  • ESP32 Compatible
  • Raspberry Pi Compatible
  • Only 2 Signal Pins
  • 7.5g Lightweight
5V logic — use a voltage divider on the ECHO pin for 3.3V boards

The HC-SR04 TRIG and ECHO pins operate at 5V logic. The TRIG pin is fine driven from 3.3V GPIO, but the ECHO pin outputs 5V which can damage ESP32 or Raspberry Pi inputs. Use a simple two-resistor voltage divider (1kΩ and 2kΩ) to drop ECHO to 3.3V before connecting to a 3.3V board.

Electrical & Physical Specifications

Full specifications for the HC-SR04 ultrasonic distance sensor module. All values at DC 5V supply unless stated.

Model Number
HC-SR04 (HCSR04)
Working Voltage
DC 5V
Quiescent Current
Less than 2 mA
Level Output (High)
5V
Level Output (Low)
0V
Detection Range
2 cm – 450 cm
Precision
Up to 3 mm (0.3 cm)
Sensing Angle
Not more than 15°
Ultrasonic Frequency
40 kHz
Trigger Input Signal
10 µs TTL pulse minimum
Distance Formula
Distance = (Echo high time × 340 m/s) ÷ 2
Pins
VCC, TRIG, ECHO, GND
Weight
7.5 g
MCU Compatibility
Arduino, ESP32 (with divider on ECHO), Raspberry Pi
How distance is calculated

After the 10 µs trigger pulse, the module fires eight 40 kHz bursts and raises ECHO HIGH for the duration the sound takes to travel to the target and back. Divide the echo time in microseconds by 58 to get centimetres, or by 148 for inches.

Pinout & Wiring Instructions

The HC-SR04 has four pins in a single row: VCC, TRIG, ECHO, GND — left to right when the two transducer cylinders face you.

HC-SR04 Pinout

TX RX VCC TRIG ECHO GND V T E G

VCC  ·  TRIG  ·  ECHO  ·  GND

  1. 1
    VCC → 5V

    Connect VCC to the 5V pin of your Arduino. Do not use 3.3V — the module requires 5V to operate.

  2. 2
    GND → GND

    Common ground with your Arduino or ESP32.

  3. 3
    TRIG → Digital Pin (e.g. D9)

    Send a 10 µs HIGH pulse to trigger a reading. 3.3V GPIO is sufficient to trigger the module.

  4. 4
    ECHO → Digital Pin (e.g. D10)

    Reads the pulse duration. Arduino: connect directly. ESP32 / RPi: use a 1kΩ + 2kΩ voltage divider to drop 5V to 3.3V before connecting.

  5. 5
    Calculate distance

    Use pulseIn(ECHO, HIGH) to measure µs. Divide by 58 for cm or 148 for inches. The NewPing library simplifies this.

Minimum 60 ms between readings

Wait at least 60 ms between trigger pulses to allow ultrasonic echoes to clear. Triggering too quickly causes false short-range readings from the previous cycle's echo.

Applications & Use Cases

The HC-SR04 is one of the most widely used sensors in hobbyist and maker projects. Its low cost, simple two-wire interface, and 4.5 m range make it ideal for anything from obstacle avoidance to liquid level monitoring.

Obstacle Avoidance Robots

Mount on a servo for sweeping detection or fixed for forward collision avoidance on Arduino and ESP32 rovers.

Parking Sensor

DIY garage or vehicle parking aid — beeps when an object is detected within a set distance.

Liquid Level Monitoring

Measure water tank, sump, or container fill levels without contact with the liquid.

People / Object Counter

Detect when someone passes through a doorway or breaks the beam between two points.

Height Measurement

Non-contact height gauging for conveyor systems, sorting machines, or interactive installations.

Home Automation

Trigger lights, fans, or alarms based on detected presence or proximity with ESPHome or Home Assistant.

ESPHome integration

The HC-SR04 is natively supported in ESPHome with the ultrasonic sensor platform. Define TRIG and ECHO pins and get distance readings directly in Home Assistant with no extra code.

Frequently Asked Questions

The module itself needs 5V on VCC to function. The TRIG pin can be driven from 3.3V GPIO. The ECHO pin outputs 5V however, which can damage 3.3V microcontrollers — use a 1kΩ/2kΩ voltage divider or a logic level shifter on the ECHO line before connecting to an ESP32 or Raspberry Pi.
The blind zone starts at 2 cm. Objects closer than 2 cm may not be reliably detected. For very close-range sensing consider an IR proximity sensor instead.
Measure the ECHO HIGH duration in microseconds using pulseIn(echoPin, HIGH). Divide by 58 to get centimetres, or by 148 for inches. This accounts for the round-trip travel of the sound pulse. The NewPing Arduino library handles all of this automatically.
Wait at least 60 ms between trigger pulses. Faster polling risks detecting the echo from the previous cycle, giving spuriously short readings. In practice 100 ms (10 readings per second) is a safe rate for most applications.
Soft or angled surfaces absorb or scatter ultrasonic energy, reducing effective range and accuracy. For best results aim at flat, hard surfaces such as walls, water, or solid objects. Angled surfaces should be within roughly 15° of perpendicular to the sensor face.
Yes — the NewPing library by Tim Eckel is the most popular choice. Install it via the Arduino Library Manager. It simplifies triggering, echo timing, and includes median filtering to reduce noise. For ESPHome users, the built-in ultrasonic platform works out of the box.

You may also like