Academic ProjectEmbedded SystemsEN1190 — UoM

Water Level Detector

Team EN-14 BROVO6 · Department of Electronic & Telecommunication Engineering, University of Moratuwa · October 2022

Module lecturer: Mr. Ajith Pasqual


Problem & Solution

Problem

Household water tanks — often located on rooftops or at the back of the property — are hard to monitor. Forgetting to switch off the pump causes water overflow (wastage), power wastage, motor winding damage, and well-water depletion. During Sri Lanka's 2022 power cuts, knowing the water level in advance allowed residents to refill before the blackout. A user survey (n = 91.7% agreement) validated the need for a mobile alert system.

Solution

A compact IoT device mounted on the inside of the tank lid uses an HC-SR04 ultrasonic sensor to measure the air gap between the sensor and the water surface. The ATmega328P calculates the water level percentage using:

% Water = (Tank Height − Empty Space) / Tank Height × 100

The result is transmitted via HC-06 Bluetooth to a custom Android app. Notifications are sent when the level drops below 15% (low — alert to refill) or rises above 95% (overflow — alert to switch off pump). The user can also set the tank volume for volumetric display (optional).

Technical Specifications

MicrocontrollerATmega328P (28-SPDIP) — 8-bit RISC, 32KB Flash, 2KB SRAM
Distance SensorHC-SR04 Ultrasonic (2 cm – 400 cm, ±3 mm)
WirelessHC-06 Bluetooth (≤ 100 m, 2.4 GHz FHSS, up to 2.1 Mb/s)
Clock16 MHz Crystal Oscillator
Power7.5 V battery → LM7805 → 5 V regulated (rechargeable)
PCB Size55 mm × 53 mm (Altium Designer)
Enclosure125 mm × 75 mm × 40 mm (SolidWorks)
Weight≈ 468 g
Power Consumption≈ 695 mW total
Alert Threshold (low)Below 15% water remaining
Alert Threshold (high)Above 95% water level (overflow warning)
Total Budget7,752 LKR

Hardware Design

Circuit & PCB (Altium Designer)

The 7.5 V battery is regulated to 5 V by an LM7805. Two smoothing capacitors reduce ripple. A 4-pin header connects to the HC-SR04 ultrasonic sensor; another 4-pin header connects to HC-06. A voltage divider (220Ω + 470Ω) drops the 5 V TX signal to 3.3 V for the HC-06 RX pin. A LED and on/off switch are included on the board. The 16 MHz crystal provides the ATmega328P clock. PCB: 55 mm × 53 mm, trace width 8.5 mm (power), clearance 0.85 mm, hole size 0.85 mm.

Enclosure (SolidWorks)

125 mm × 75 mm × 40 mm two-part plastic enclosure. Top casing has two round holes for the ultrasonic sensor's transmit/receive transducers, holes for the LED and switch, and four 3 mm × 20 mm holes to bolt the two halves together. Base casing has four 3 mm × 5 mm standoffs to mount the PCB, and four external holes to fix the device to the tank lid.

Mobile App & UI

A custom Android application connects to the HC-06 Bluetooth module. Setup steps:

  1. Install the app and pair Bluetooth with HC-06.
  2. Open the app and connect to HC-06.
  3. With tank empty, press Set Tank Height to calibrate the zero reference.
  4. Optionally enter the tank volume for litre-based display.
  5. Live percentage is shown on the home screen and as push notifications.
  6. Alerts fire below 15% (low) and above 95% (overflow).

The app UI features a clear percentage gauge and a notification toggle. Data is polled every 1.5 s from the sensor and streamed via Bluetooth serial at 9600 baud.

Firmware (ATmega328P — Arduino)

The firmware triggers the HC-SR04 (10 µs TRIG pulse), measures the echo pulse width via pulseIn(), divides by 58 to get distance in cm, and transmits it via HC-06 at 9600 baud every 1.5 s. The app computes the water percentage from the received distance and the calibrated tank height.

Budget (Total: 7,752 LKR ≈ export price 8,000 LKR)

ItemQtyTotal (LKR)
ATmega328P Microcontroller12,000
Ultrasonic Sensor HC-SR041250
Bluetooth Module HC-061900
16 MHz Crystal Oscillator125
Rechargeable Battery11,000
LED12
On/Off Switch120
Air Suckers (mounting)250
Pin headers (4-pin × 2, 2-pin × 2)4120
Capacitors (0.33 µF, 0.11 µF, 22 pF × 2)490
Resistors (220 Ω × 2, 470 Ω × 1)325
PCB Fabrication1500
Enclosure (SolidWorks + print)12,800

Results & Challenges

The final device successfully measured the water level in a tank and displayed the percentage on the Android app in real time. Push notifications for low and overflow states were verified.

Key challenges overcome:

  • Confirming ultrasonic reflection off a water surface — initially uncertain, ultimately verified experimentally.
  • Finding a Bluetooth module with ≥ 100 m range (HC-06 supports up to 100 m vs. typical 10 m modules).
  • Enclosure dimensions and waterproofing for outdoor/tank-lid installation.
  • PCB design under limited prior experience with Altium's routing rules.

Team

MANIMOHAN T.MADHUSHAN R.M.S.MADUSAN A.K.C.S.MALANBAN K.

Follow Me

WhatsApp Chat