π MODULE 5 β Ultrasonic Distance Meter
This module is practical, so lessons should be focused on concepts, circuit, coding, testing, and troubleshooting rather than very long theory.
π Lesson 5.1 β What is Ultrasonic Sensor?
π― Learning Objectives
After completing this lesson, students will be able to:
β Understand what an Ultrasonic Sensor is
β Understand how distance measurement works
β Identify HC-SR04 sensor pins
β Understand Trigger and Echo pins
β Understand real-world applications of ultrasonic sensors
β Prepare for building an Ultrasonic Distance Meter project
1. Introduction
Have you ever wondered how a robot detects obstacles without touching them?
How does a car know when it is close to a wall while parking?
How do automatic water tank monitoring systems measure water levels?
The answer is often:
Ultrasonic Sensors
Ultrasonic sensors can measure distance without physically touching an object.
This makes them very useful in robotics, automation, and IoT projects.
2. What is an Ultrasonic Sensor?
An ultrasonic sensor is an electronic device that measures distance using sound waves.
Instead of using light, it uses:
Ultrasonic Sound Waves
These sound waves travel through the air, hit an object, and return to the sensor.
The sensor calculates the distance based on the time taken for the sound wave to return.
3. What Does “Ultrasonic” Mean?
Humans can hear sounds between:
20 Hz to 20,000 Hz
Sounds above:
20,000 Hz
are called:
Ultrasonic Sounds
These sounds cannot be heard by humans.
The HC-SR04 sensor operates at approximately:
40 kHz
which is well above human hearing range.
4. Working Principle of Ultrasonic Sensor
The sensor works using the principle of:
Echo
Example:
If you shout in a valley:
Hello!
The sound reflects back.
This reflected sound is called an:
Echo
Ultrasonic sensors use the same principle.
5. How HC-SR04 Measures Distance
Step 1
Arduino sends a signal to the Trigger pin.
β
Step 2
Sensor emits ultrasonic waves.
β
Step 3
Waves travel through air.
β
Step 4
Waves hit an object.
β
Step 5
Waves reflect back.
β
Step 6
Echo pin sends timing information to Arduino.
β
Step 7
Arduino calculates distance.
6. HC-SR04 Ultrasonic Sensor
The HC-SR04 is the most commonly used ultrasonic sensor in Arduino projects.
Advantages:
β Low Cost
β Easy to Use
β Accurate
β Beginner Friendly
β Large Community Support
7. HC-SR04 Pin Description
The sensor has four pins:
| Pin | Function |
|---|---|
| VCC | Power Supply (5V) |
| TRIG | Trigger Signal Input |
| ECHO | Echo Signal Output |
| GND | Ground |
VCC
Provides power to the sensor.
Connect to:
5V
on Arduino.
GND
Ground connection.
Connect to:
GND
on Arduino.
TRIG Pin
Used to start distance measurement.
Arduino sends a short pulse to this pin.
ECHO Pin
Returns the reflected signal timing.
Arduino measures this time to calculate distance.
8. Detection Range
Typical HC-SR04 Specifications:
| Parameter | Value |
|---|---|
| Operating Voltage | 5V |
| Frequency | 40 kHz |
| Minimum Range | 2 cm |
| Maximum Range | 400 cm |
| Accuracy | Β±3 mm |
9. Real-World Applications
Ultrasonic sensors are widely used in:
Distance Measurement
Measuring object distance.
Obstacle Avoiding Robots
Detecting obstacles.
Smart Parking Systems
Vehicle parking assistance.
Water Level Monitoring
Measuring tank levels.
Industrial Automation
Object detection systems.
Security Systems
Motion and object detection.
10. Advantages of Ultrasonic Sensors
Contactless Measurement
No physical contact required.
Good Accuracy
Provides reliable readings.
Low Cost
Affordable for students.
Easy Interfacing
Only four pins.
11. Limitations
Ultrasonic sensors may struggle with:
Soft Surfaces
Sound may be absorbed.
Very Small Objects
Detection becomes difficult.
Irregular Shapes
Echo may scatter.
Heavy Wind Environments
Can affect accuracy.
12. Common Beginner Mistakes
Mistake 1
Connecting VCC and GND incorrectly.
Mistake 2
Mixing Trigger and Echo pins.
Mistake 3
Expecting accurate readings beyond 4 meters.
Mistake 4
Blocking the sensor with hands during testing.
13. Best Practices
β Use stable 5V supply
β Keep sensor facing object directly
β Avoid excessive vibration
β Test at multiple distances
β Use proper wiring
π Summary
In this lesson, we learned:
β What an Ultrasonic Sensor is
β How HC-SR04 works
β Echo principle
β Sensor pins
β Distance measurement concept
β Applications and limitations
The HC-SR04 ultrasonic sensor is one of the most useful sensors in Arduino robotics and automation because it can measure distance accurately without touching the object.
π― Quiz
1. What type of waves does HC-SR04 use?
A. Light Waves
B. Radio Waves
C. Ultrasonic Sound Waves β
D. Infrared Waves
2. Which pin starts measurement?
A. VCC
B. GND
C. TRIG β
D. ECHO
3. Which pin returns timing information?
A. TRIG
B. ECHO β
C. VCC
D. GND
4. What is the maximum typical range of HC-SR04?
A. 50 cm
B. 100 cm
C. 400 cm β
D. 1000 cm
5. What principle does the sensor use?
A. Reflection of Sound (Echo) β
B. Magnetism
C. Heat Detection
D. Light Reflection
π Assignment
Task 1
Label all four pins of the HC-SR04 sensor.
Task 2
Draw the working principle diagram of an ultrasonic sensor.
Task 3
List five real-world applications of ultrasonic sensors.
Task 4
Research the specifications of HC-SR04 and create a summary table.
Task 5
Explain the difference between ultrasonic sensing and IR sensing.