Ultrasonic Sensor HC-SR04 for IoT: Working, Applications, Circuit, and Integration Guide
Discover how the Ultrasonic Sensor HC-SR04 works and how to use it in IoT projects. This detailed guide covers its working principle, pin configuration, interfacing with Arduino, applications in smart systems, and complete circuit setup. Ideal for beginners and IoT developers looking to integrate distance sensing in real-time projects.

Device Overview
Introduction
Ultrasonic sensors have become a key component in modern electronics and Internet of Things (IoT) applications. Among them, the HC-SR04 Ultrasonic Sensor is one of the most popular and affordable distance-measuring devices. It uses high-frequency sound waves to detect the distance between objects and is widely used in robotics, automation, water level monitoring, parking sensors, and more.
This guide provides complete insights into the Ultrasonic Sensor HC-SR04, including its working principle, specifications, interfacing with Arduino, applications, advantages, and integration tips for IoT projects.
What is Ultrasonic Sensor HC-SR04?
The HC-SR04 is an ultrasonic distance measuring sensor that calculates the distance to an object by sending and receiving sound waves. It uses the time-of-flight method to determine how long it takes for the sound to reflect back from a surface.
Working Principle
HC-SR04 works based on ultrasonic echolocation — similar to how bats and dolphins navigate.
-
The Trigger pin sends an ultrasonic pulse (40kHz).
- This pulse travels through the air and hits an object.
-
The reflected signal is captured by the Echo pin.
- The sensor calculates distance using the formula:
Speed of sound = ~343 m/s in air
Technical Specifications
Parameter | Value |
---|---|
Model | HC-SR04 |
Operating Voltage | 5V DC |
Operating Current | 15mA |
Frequency | 40 kHz |
Measuring Range | 2 cm to 400 cm (4 meters) |
Accuracy | ±3 mm |
Measuring Angle | ≤ 15° |
Trigger Input Signal | 10µs TTL pulse |
Echo Output Signal | TTL pulse (width = distance) |
Module Size | 45mm × 20mm × 15mm |
Pin Configuration
Pin | Name | Description |
---|---|---|
1 | VCC | +5V Power Supply |
2 | Trig | Trigger Input (10µs pulse) |
3 | Echo | Echo Output (pulse width) |
4 | GND | Ground |
Interfacing HC-SR04 with Arduino
Required Components:
- 1x Ultrasonic Sensor HC-SR04
- 1x Arduino Uno / Nano / Mega
- Jumper wires
- Breadboard (optional)
Circuit Diagram:
-------- -------
VCC → 5V
GND → GND
Trig → Digital Pin 9
Echo → Digital Pin 10
Sample Arduino Code
Output:
The distance (in cm) of the object from the sensor will be displayed in the Serial Monitor.
Applications of HC-SR04 Ultrasonic Sensor
- Water level measurement
- Smart dustbins
- Parking assistance system
- Obstacle detection in robotics
- Industrial automation
- IoT-based security systems
- Blind assistive devices
- Smart agriculture (e.g., irrigation level detection)
- Home automation
Advantages of Using HC-SR04
- Low cost and easily available
- High accuracy (±3 mm)
- Easy to interface with microcontrollers
- Reliable and consistent output
- Works in dark or non-visual environments
Limitations
- Can be affected by temperature and humidity
- Works best with flat, smooth surfaces
- Limited angle (15° cone)
- Not suitable for transparent or absorbent objects
Types of Ultrasonic Sensors
Although HC-SR04 is the most popular, here are other types used in IoT:Sensor Name | Features |
---|---|
HC-SR04 | Standard, low-cost, most used |
JSN-SR04T | Waterproof, suitable for outdoor projects |
MB1020 (MaxBotix) | High precision, industrial grade |
HY-SRF05 | Enhanced range and accuracy over HC-SR04 |
Integration Tips for IoT Projects
- Always add a small capacitor across VCC and GND to eliminate noise.
- Use software or hardware filters to reduce false signals.
- For long-range accuracy, prefer waterproof sensors like JSN-SR04T.
- Combine with NodeMCU/ESP32 for WiFi-enabled IoT setups.
- Ensure echo pin timing is handled properly to avoid incorrect distance readings.
Conclusion
The Ultrasonic Sensor HC-SR04 is an ideal choice for distance measurement in various DIY and professional IoT applications. With simple interfacing, accurate output, and affordable pricing, it remains a top pick among makers and engineers. Whether you’re building a smart water level detector or an obstacle-avoiding robot, the HC-SR04 is a reliable and efficient sensor to integrate.
Where to Buy
Platform | Price | Action |
---|---|---|
|
₹279 | Buy Now |
Prices may vary. Click on "Buy Now" to check current availability and pricing.
Administrator
Frequently Asked Questions
Common questions about Ultrasonic Sensor HC-SR04 for IoT: Working, Applications, Circuit, and Integration Guide. Find answers to the most frequently asked questions.
User Reviews & Comments
Share your experience with this IoT device. Your feedback helps our community make informed decisions!
Share Your Experience
Help others by sharing your thoughts about this IoT device.
Related Devices
Explore more IoT devices in the same category
A vibration sensor is a crucial device used to detect and measure vibrations in machines, structures, and environments. This complete guide covers how vibration sensors work, their different types, applications across industries, and factors to consider before selection. Learn how these sensors improve safety, enhance performance, and prevent costly equipment failures.
Discover everything about IR sensors used in modern IoT applications. Learn their types, working principles, interfacing methods, and real-world uses. This complete guide helps developers and engineers choose the best IR sensor for smart electronics and automation projects with reliable performance.
Discover how photoresistors (LDRs) work in IoT projects. Learn about their functions, real-world applications, circuit integration, and why they are essential in modern smart systems. This detailed guide helps electronics and IoT enthusiasts understand light sensors and their role in automation. Perfect for students, hobbyists, and developers looking to build smarter, light-based solutions.
The BMP180 sensor is a high-precision digital barometric pressure sensor widely used for measuring atmospheric pressure and temperature. This detailed guide covers its key features, specifications, working principle, and practical applications. Learn how the BMP180 delivers accurate environmental data for various projects, along with benefits and usage tips to ensure reliable and efficient performance.
The Hall Effect Sensor is a key electronic component that detects magnetic fields and converts them into electrical signals. Widely used in IoT devices, robotics, and industrial systems, this sensor provides accurate, contactless, and reliable performance. In this blog, we explain how the Hall Effect Sensor works, its types, advantages, and real-world applications. From current measurement to speed detection, it plays a vital role in automation and smart technology.
Reed Switch is a simple but powerful electronic component widely used in IoT devices and smart applications. This complete guide explains its working principle, different types, key advantages, and real-world applications. Whether you are an engineer, student, or IoT enthusiast, understanding Reed Switch technology helps in building efficient, reliable, and cost-effective projects with modern sensor solutions.
Bavaliya Nayan
1 month agoSuper 😍 bro it's working 💪