Course Content
IoT Engineering Course using ESP32 with 12 Real-World Projects

πŸ“˜ Lesson 7.1 – What is an Ultrasonic Sensor?


πŸ”Š What is an Ultrasonic Sensor?

An Ultrasonic Sensor is an electronic device that measures distance by using high-frequency sound waves (ultrasound).

It works on the principle of:

Sound Wave Reflection (Echo Principle)

The sensor sends ultrasonic waves and measures the time taken for the echo to return after hitting an object.

This time is converted into distance.


πŸ“¦ Common Ultrasonic Sensor Used

πŸ‘‰ HC-SR04 Ultrasonic Sensor

πŸ“Œ Working Principle

1️⃣ Trigger pin sends ultrasonic pulse
2️⃣ Sound waves travel in air
3️⃣ Waves hit object (like water surface)
4️⃣ Echo returns to sensor
5️⃣ Echo pin measures return time
6️⃣ Distance is calculated using formula


πŸ“ Distance Formula

Distance = Speed of SoundΓ—Time \ 2

Speed of sound β‰ˆ 343 m/s

In Arduino/ESP32 projects, we use:

Β 
Β 
Distance (cm) = Duration Γ— 0.034 / 2
Β 

πŸ“ Pins of HC-SR04

Pin Function
VCC 5V Power
Trig Sends pulse
Echo Receives echo
GND Ground

πŸ“Š Why Use Ultrasonic Sensor in Water Tank?

Instead of detecting water by contact (like conductive sensor), ultrasonic:

βœ” Measures distance from top of tank
βœ” No direct contact with water
βœ” No corrosion
βœ” More accurate
βœ” Long life
βœ” Suitable for permanent installation


πŸ“Œ How It Works in Water Tank System

  • Sensor placed at top of tank

  • Measures distance to water surface

  • If distance is large β†’ Tank Empty

  • If distance is small β†’ Tank Full

Example:

Distance Tank Status
25 cm Low Water
5 cm Tank Full

πŸ“Œ Advantages

βœ” Non-contact measurement
βœ” Accurate distance calculation
βœ” Long lifespan
βœ” Works with ESP32 easily
βœ” Industry-level solution


πŸ“Œ Disadvantages

⚠ Affected by temperature changes
⚠ Not good in heavy mist or steam
⚠ Slightly higher cost than conductive sensor


πŸ“Œ Applications

  • Water tank monitoring

  • Smart irrigation systems

  • Liquid level monitoring

  • Obstacle detection

  • Parking sensors

  • Industrial automation


🎯 What Students Will Learn in This Lesson

  • Ultrasonic sensor working principle

  • Echo timing concept

  • Distance calculation

  • Non-contact liquid measurement

  • Why ultrasonic is better than basic water sensor


πŸ“Œ Lesson Summary

An ultrasonic sensor measures distance using sound wave reflection.

In the Smart Water Management System, it is used to:

  • Measure water level accurately

  • Prevent overflow

  • Prevent dry run

  • Improve system reliability

This makes the system more professional and industry-ready.

Scroll to Top