Ultrasonic Water Level Monitor: Real-Time Liquid Height Measurement with Arduino and I2C LCD
Never again will a tank overflow or run out of water! In this project, an Arduino Uno measures the water level in a container non-invasively using an HC-SR04 ultrasonic sensor, and a 16×2 I2C LCD screen shows the precise water depth in centimeters.

Watch the Video
For written instructions, continue reading this page, or watch the video guide.
Components Used
- Microcontroller: Arduino Uno R3
- Distance Sensor: HC-SR04 Ultrasonic Sensor Module
- Display: 16×2 LCD Display with PCF8574 I2C Backpack

Circuit Wiring & Schematic
| Arduino | HC-SR04 | 16×2 I2C LCD Display |
| 5V | VCC | VCC |
| GND | GND | GND |
| Pin 12 | Trig Pin | |
| Pin 10 | Echo Pin | |
| Pin A4 | SDA | |
| Pin A5 | SCL |

Required Libraries
In your Arduino IDE, install these libraries by selecting Sketch → Include Library → Manage Libraries.
HCSR04 library
Manages the HC-SR04 sensor’s distance calculations.

LiquidCrystal I2C library
Controls the 16×2 LCD display over I2C

Arduino Code
#include <LiquidCrystal_I2C.h>
#include <HCSR04.h>
HCSR04 hc(12, 10); // Initialize HCSR04 class (Trig Pin = 12, Echo Pin = 10)
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set LCD address to 0x27 for 16x2 display
float resetDistance;
void setup()
{
// Initialize LCD
lcd.init();
// Turn on LCD backlight
lcd.backlight();
Serial.begin(9600);
}
void loop()
{
float distance = hc.dist(); // Measure air distance from sensor to water surface
// Process measurement if water surface is within range (< 14 cm)
if (distance < 14) {
// Calculate actual water depth: Full depth (12.50 cm) minus air gap distance
resetDistance = ((12.50) - (distance));
lcd.clear();
// Display label on top row
lcd.setCursor(0, 0);
lcd.print("Deep");
// Display calculated water height on bottom row
lcd.setCursor(0, 1);
lcd.print(resetDistance);
Serial.println(resetDistance);
delay(150);
}
}
How It Works
The HC-SR04 ultrasonic sensor, which is mounted at the top of the container and faces downward, measures the air gap distance by sending out high-frequency sound waves that reflect off the water’s surface. The Arduino determines the real height of the liquid within by subtracting this air gap measurement from the container’s overall height of 12.50 cm. The 16×2 I2C LCD panel updates in real time with the recalculated water depth whenever liquid is found within 14 cm of the sensor.

