
Ultrasonic Sensor Working Principle
In this blog, we will explore the working principle of ultrasonic sensors and their applications.
Introduction to Ultrasonic Sensors
Ultrasonic sensors operate by emitting sound waves at frequencies beyond human hearing. These sensors are widely used in industrial applications for detecting objects, measuring distances, and identifying hidden discontinuities in metals, plastics, ceramics, and liquids. Unlike optical sensors, ultrasonic sensors rely on sound instead of light, making them effective in various environmental conditions.
How Does an Ultrasonic Sensor Work?
Ultrasonic sensors emit short, high-frequency sound pulses at regular intervals. These sound waves travel through the air at the speed of sound. When they encounter an object, they reflect back as an echo. The sensor then calculates the distance to the object based on the time taken for the echo to return.
Components of an Ultrasonic Sensor
The standard ultrasonic sensor consists of:
- Transmitter: Emits ultrasonic waves.
- Receiver: Detects reflected waves.
- Microcontroller Interface: Processes signals and computes distances.
A commonly used module, the HC-SR04, has the following pin configuration:

- VCC: +5V power supply.
- TRIG: Trigger input that receives a pulse from a microcontroller.
- ECHO: Output that sends a pulse back when the echo is received.
- GND: Ground connection.
Ultrasonic Sensor Features
- Supply Voltage: 5V (DC)
- Operating Current: 15mA
- Modulation Frequency: 40kHz
- Detection Range: 2 cm – 400 cm
- Accuracy: ±0.3 cm
- Beam Angle: Max 15 degrees
Working Principle of Ultrasonic Sensors

- The sensor transmits a trigger pulse (typically 10µs) via the TRIG pin.
- It then emits eight 40kHz ultrasonic waves and waits for an echo.
- When the reflected signal is received, the ECHO pin sends a pulse.
- The time taken for the pulse to return is used to calculate distance.
Distance Calculation

The distance between the sensor and the object can be calculated using the formula: Distance = (Speed of Sound × Time) / 2
Since the speed of sound in air is approximately 343 m/s, the formula becomes: Distance = (343 × Echo Pulse Time) / 2
Interfacing an Ultrasonic Sensor with Arduino

To use an ultrasonic sensor with an Arduino Uno, you need:
- Arduino Uno Board
- HC-SR04 Ultrasonic Sensor
- Connecting Wires
Arduino Code for Ultrasonic Sensor
#define echoPin 2 // Echo pin of HC-SR04
#define trigPin 3 // Trigger pin of HC-SR04
long duration;
int distance;
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;
Serial.print(“Distance: “);
Serial.print(distance);
Serial.println(” cm”);
}

Applications of Ultrasonic Sensors
- Obstacle Detection: Used in autonomous robots, drones, and automotive parking assistance systems.
- Distance Measurement: Measures object distances in industrial automation.
- Liquid Level Monitoring: Determines the depth of liquids in tanks and wells.
- Mapping and Navigation: Used in robotic mapping and pathfinding.
- Automatic Faucets and Doors: Enables hands-free operation in public restrooms and buildings.
Conclusion
Ultrasonic sensors provide a reliable, cost-effective solution for object detection and distance measurement in various industries. Their ability to work in challenging environments makes them a preferred choice for automation and robotics applications. Stay tuned for more educational content from Regent Electronics!
Related Articles:
- Using Ultrasonic Sensors with Raspberry Pi
- Raspberry Pi Ultrasonic Sensor Interface Tutorial
For further learning, check out our instructional videos and blogs.