An Arduino-based automated water management system designed for reliable, real-time water level monitoring and pump control with zero manual intervention.
A 4-case hysteresis-driven water management system that monitors tank levels using multiple sensors and automatically controls a solenoid valve to prevent overflow, dry running, and water wastage.
- Arduino Nan0
- 3x Water Level Sensors (D11, D12, D5)
- NC (Normally Closed) Solenoid Valve
- Relay Module (Active LOW)
- SSD1306 0.96" OLED Display (Works Even Without Display)
- 4x Status LEDs (White, Green, Blue, Red)
| Pin | Component |
|---|---|
| D2 | Relay (Active LOW) |
| D5 | Top Sensor (Overflow) |
| D6 | White LED |
| D7 | Red LED |
| D8 | Blue LED |
| D9 | Green LED |
| D11 | Bottom Sensor (Pump Trigger) |
| D12 | Mid Sensor (Tank Full) |
- 4-Case Hysteresis Logic — smooth state transitions with independent touch and release delays prevent false triggers and relay chatter
- Double Sensor Protection — dual confirmation system requires continuous sensor contact before any action, eliminating noise-based false switching
- Zero Water Overflow — NC solenoid ensures pump is off by default; water cannot overflow even on power failure
- Zero Dry Run — pump only activates when water source is confirmed present
- 100% Uptime Logic — non-blocking millis() based code, no delay() in main loop, system never freezes
- Real-time OLED Display — display synced to relay state, not sensor state, showing true system status
- LED Status Indicators — each LED directly synced to its sensor for instant fault diagnosis
- System Halt Protection — overflow triggers a hardware halt requiring physical reset, preventing repeated overflow cycles
- Transition Indicators — dual LED transitions during state changes for clear visual feedback
| Case | Condition | Action | LED |
|---|---|---|---|
| 1 | Tank Empty | Pump OFF | White |
| 2 | Water Source Detected | Pump ON, Filling | Green |
| 3 | Tank Full | Pump OFF | Blue |
| 4 | Overflow | System HALT, Reset Required | Red |
[Case 1] --5s D11 touch--> [Case 2] --5s D12 touch--> [Case 3] --2s D5 touch--> [Case 4 HALT] [Case 1] <--5s D11 release-- [Case 2] <--5s D12 release-- [Case 3]
Each sensor has independent confirmation delays on both touch and release, implementing true hysteresis:
- Touch delay — sensor must be continuously wet for the full delay before state changes
- Release delay — sensor must be continuously dry for the full delay before reverting
- If contact breaks before delay completes, timer resets from zero
The relay and display only update after the delay is satisfied, while LEDs respond instantly for real-time fault diagnosis. The NC solenoid guarantees safe state on power loss — pump is always OFF by default.
Wire.hAdafruit_GFX.hAdafruit_SSD1306.h
- Clone the repository
- Install required libraries via Arduino Library Manager
- Upload
smart_water_management.inoto your Arduino Uno - Wire components as per pin configuration table
- Power up — system initializes with splash screen and enters Case 1
MIT License