HC-SR04 Ultrasonic Sensor

HC-SR04 Ultrasonic Sensor
Atribot team

Written by

Atribot team

Last updated

June 10, 2026

Introduction

What if you could measure the distance to an object without touching it? Whether it's a robot avoiding obstacles, a smart parking system detecting vehicles, or a water tank monitoring its level, accurate distance measurement is essential in many modern electronic systems.

The HC-SR04 Ultrasonic Sensor is one of the most widely used distance sensors in electronics and robotics. Instead of relying on light, it uses ultrasonic sound waves to detect objects and calculate their distance. This makes it reliable in various lighting conditions and suitable for many automation projects.

Thanks to its affordability, accuracy, and ease of use, the HC-SR04 has become a favorite among students, hobbyists, and engineers. It is commonly used in robotics, obstacle detection systems, smart automation projects, and educational electronics applications.

In this article, you will learn about the HC-SR04 sensor's main parts, pin configuration, technical specifications, working principle, advantages, disadvantages, and real-world applications.

Main Parts

1. Transmitting Transducer

The transmitting transducer generates ultrasonic sound waves at a frequency of 40 kHz.

Functions:

  • Produces ultrasonic pulses

  • Sends sound waves toward objects

  • Initiates the distance measurement process

2. Receiving Transducer

The receiving transducer detects ultrasonic waves reflected from nearby objects.

Functions:

  • Receives reflected sound waves

  • Converts sound signals into electrical signals

  • Helps determine object distance

3. Oscillator

The oscillator generates the required frequency for ultrasonic transmission.

Functions:

  • Produces stable 40 kHz signals

  • Drives the transmitting transducer

  • Ensures accurate measurements

4. LM324 Operational Amplifier

The LM324 is used to process ultrasonic signals.

Functions:

  • Amplifies received signals

  • Filters unwanted noise

  • Improves detection accuracy

5. MAX3232 IC

The MAX3232 assists with signal processing and communication functions.

Functions:

  • Performs voltage level conversion

  • Supports serial communication requirements

  • Enhances signal reliability

Pinouts

The HC-SR04 sensor contains four pins.

Swipe right to view full table

Pin

Description

VCC

Power Supply (5V)

Trig

Trigger Input

Echo

Echo Output

GND

Ground

VCC

Provides power to the sensor module.

Trig

Receives a trigger pulse that starts ultrasonic transmission.

Echo

Outputs a pulse whose duration corresponds to the measured distance.

GND

Provides the common ground connection.

Specifications

Swipe right to view full table

Parameter

Specification

Operating Voltage

5V DC

Operating Current

15mA

Working Frequency

40kHz

Measuring Range

2cm – 400cm

Measuring Angle

15°

Distance Accuracy

±3mm

Trigger Signal

10µs TTL Pulse

Output Signal

TTL Pulse

Operating Temperature

-15°C to 70°C

Dimensions

45mm × 20mm × 15mm

Working Principle

The HC-SR04 works on the principle of ultrasonic wave reflection.

Step 1: Trigger Signal

A 10-microsecond pulse is applied to the Trig pin.

Step 2: Ultrasonic Transmission

The sensor transmits eight ultrasonic pulses at 40 kHz.

Step 3: Object Reflection

The sound waves travel through the air and reflect from an object's surface.

Step 4: Echo Reception

The receiving transducer detects the reflected ultrasonic waves.

Step 5: Distance Calculation

The sensor calculates the distance based on the time taken for the sound waves to travel to the object and return.

Advantages & Disadvantages

The HC-SR04 is widely used because of its accuracy and simplicity. However, it also has certain limitations.

Advantages

  • Accurate distance measurement

  • Non-contact sensing

  • Low cost

  • Easy to interface

  • Low power consumption

  • Wide measuring range

  • Reliable performance

  • Suitable for robotics applications

Disadvantages

  • Affected by soft surfaces

  • Limited detection angle

  • Cannot operate in a vacuum

  • Sensitive to environmental conditions

  • Difficulty detecting very small objects

  • Slower than some laser-based sensors

Applications

The HC-SR04 is used in a wide variety of electronic and automation systems.

1. Obstacle Avoidance Robots

Detects obstacles and helps robots navigate safely.

2. Distance Measurement Systems

Measures the distance between the sensor and objects.

3. Automatic Parking Systems

Assists in vehicle parking by detecting nearby obstacles.

4. Water Level Monitoring

Measures liquid levels in tanks and containers.

5. Smart Dustbins

Detects hand movement and automatically opens the lid.

6. Security Systems

Detects nearby movement and object presence.

7. Industrial Automation

Used for object detection and process monitoring.

8. Smart Traffic Systems

Supports vehicle detection and traffic monitoring.

9. Drone and Robot Navigation

Helps autonomous systems avoid collisions.

10. IoT and Smart Projects

Used in various automation and smart monitoring applications.

The HC-SR04 Ultrasonic Sensor is one of the most popular distance measurement sensors in electronics because it offers a simple, accurate, and affordable solution for non-contact object detection and distance measurement.