ESP32 IoT Water Level Monitor: Firebase Live Dashboard
Friday, August 28, 2026
A cloud-connected water level telemetry and automated pump control system engineered around the ESP32 microcontroller. The device continuously monitors reservoir capacity using an ultrasonic sensor conditioned by an onboard digital median filter. Telemetry is streamed in real time to Google Firebase Realtime Database and visualized on a dynamic, responsive web dashboard. The system also supports bi-directional cloud actuation for electromechanical relay switching, full offline fallback handling, audio diagnostics, and local LCD status reporting.
Key Technical Features
- Real-Time Cloud Synchronization: Connects to Google Firebase Realtime Database via continuous event streaming to provide sub-second dashboard updates and instant remote relay triggering.
- 7-Sample Median Noise Filter: Implements an onboard array sorting algorithm that collects 7 consecutive ultrasonic ping samples and selects the true median, eliminating false spikes caused by surface ripples or acoustic reflections.
- Captive Portal Wi-Fi Provisioning: Integrates
WiFiManagerto allow dynamic SSID and password configuration via a smartphone captive portal without hardcoding network credentials into firmware. - Acoustic Diagnostic Telemetry: Features a multi-tone piezoelectric buzzer engine providing distinct audible alerts for boot initialization, Wi-Fi provisioning mode, network dropouts, and critical database errors.
- Independent Power Subsystem: Powered by a 3-cell (3S) 18650 Lithium-Ion battery pack regulated through an onboard Battery Management System (BMS) and an adjustable DC-DC step-down buck converter to deliver stable 5V rails.
- Animated Dark-Mode Web Dashboard: Built with modern CSS and the modular Firebase JS SDK v9, featuring a dynamic SVG-style fluid tank visualizer that updates smoothly via CSS transitions.
Hardware Architecture & Pin Mapping
Core Processing & Telemetry
- ESP32 Dev Module: Handles Wi-Fi networking, Firebase real-time listeners, sensor math, and peripheral control.
- Ultrasonic Distance Sensor: Measures water level headspace via high-frequency acoustic echo time-of-flight.
- 16x2 Character LCD (with PCF8574 I2C Backpack): Provides local, on-site readout of system status and capacity.
- Piezoelectric Passive Buzzer: Produces multi-frequency auditory status feedback.
- 5V Electromechanical Relay: Controls external pump motors or inlet solenoid valves.
Power Subsystem
- 3S 18650 Lithium-Ion Battery Bank: High-capacity mobile DC supply.
- 3S 20A BMS Protection Module: Provides over-charge, over-discharge, and balance protection.
- DC-DC Step-Down Buck Converter: Converts battery pack voltage down to a steady, regulated 5V power bus.
GPIO Pin Allocation
GPIO 12: UltrasonicTRIGPinGPIO 13: UltrasonicECHOPinGPIO 2: 5V Relay Control Output (IN)GPIO 4: Piezo Buzzer OutputGPIO 21: 16x2 LCDSDA(I2C Data Bus)GPIO 22: 16x2 LCDSCL(I2C Clock Bus)
Sensor Conditioning & Percentage Mapping
The distance reading from the ultrasonic transducer is converted into a calibrated percentage based on physical reservoir limits:
$$\text{Water Level \%} = \text{constrain}\left( \frac{\text{Empty Distance} - \text{Measured Distance}}{\text{Empty Distance} - \text{Full Distance}} \times 100,\ 0,\ 100 \right)$$
The software enforces a deadband threshold, dispatching cloud database writes only when the fluid level fluctuates by $\ge 2\%$, significantly reducing unnecessary network bandwidth and power consumption.
Firmware Implementation (ESP32 / Arduino C++)
Web Dashboard Implementation
