An IoT-based solution for intelligent water management with real-time monitoring, automated control, and cloud integration. The system operates seamlessly in both online and offline modes while maintaining data integrity.
🎥 Watch Project Demo Video
🌐 Goto Live Website
- Key Features
- System Architecture
- Core Technologies
- Hardware Components
- Firebase Data Structure
- Installation & Setup
- Operational Workflow
- License
- Contributors
-
Role-Based Access Control
Admin:- Configure system-wide water limits and pricing
- Monitor all user activities and usage patterns
- Manage admin privileges and system settings
- Force emergency shutdown of water supply
Users:
- View real-time consumption metrics
- Receive personalized alerts and notifications
- Recharge water limits through integrated payments
- Access historical usage data
-
Hybrid Operation Mode
Seamless transition between online/offline modes with local data caching -
Automated Water Control
Servo-actuated valve management based on usage thresholds -
Time-Synchronized Logging
NTP server synchronization for accurate daily record-keeping -
Smart Notifications
OLED Display: Real-time system status and alerts
Audio/visual alerts for usage limits and system status -
Payment Integration
Razorpay-powered recharge system with transaction tracking
- Sensing Layer: Flow sensors for real-time water monitoring
- Control Layer: ESP32-based actuator management
- Visual Interface: 0.96" OLED display for status updates
- Power Management: Battery backup with TP4056 protection
- User Interface: Audio alerts via DF Mini MP3 module
| Component | Specification |
|---|---|
| Microcontroller | ESP32-WROOM-32D |
| Flow Sensor | YF-S201 Hall Effect Sensor |
| Display Module | SSD1306 0.96" OLED |
| Actuator | SG90 Servo Motor |
| Audio Module | DF Mini MP3 Player |
| Power Management | TP4056 + 1200mAh Li-ion |
| Storage | MicroSD Card (16GB) |
- Edge Computing: Local decision-making using Preferences storage
- Cloud Integration: Firebase Firestore for centralized data management
- Time Synchronization: NTP client for accurate timestamping
- Dashboard: React-based visualization and control interface
- Frontend: React 18 + Chart.js + Vite
- Backend: Firebase Firestore + Authentication
- IoT Platform: ESP32 (Arduino Core)
- Payment Gateway: Razorpay API
- Time Service: NTP Client Library
users/ [Collection]
└── {userEmail}/ [Document]
├── servoState: boolean
├── lastSeen: timestamp
├── notification: string
├── userDetails: <map> {
│ ├── fullName: string
│ ├── mobileNo: string
│ ├── emailId: string (optional)
│ ├── address: string
│ ├── accountNumber: string
│ ├── consumerNumber: string
│ ├── meterNumber: string
│ └── supplyZone: string
│ }
├── wifi_pass: string
├── wifi_ssid: string
└── monthlyUsages/ [Subcollection]
└── {YYYY-MM}/ [Document]
├── {YYYY-MM-DD}: number (daily water usage in liters)
├── {YYYY-MM-DD}: number
├── limit: number (user's monthly limit)
├── isMonthFinish: boolean
├── limitExceeded: boolean
│
├── payment/ [Subcollection]
│ └── payment_details/ [Document]
│ ├── amount: number
│ ├── date: timestamp (ISO string)
│ ├── forMonth: string (YYYY-MM)
│ ├── razor_pay_id: string
│ ├── status: string ("pending" | "Completed")
│ └── timeStamp: timestamp (ISO string)
│
└── addon/ [Subcollection]
└── {addon_id}/ [Document] (auto-generated or razor_pay_id)
├── addon_date: timestamp (ISO string)
├── amount: number
├── qty: number (liters purchased)
├── refill: number (how many times refilled)
├── razor_pay_id: string
└── status: string (always "Completed")
admin/ [Collection]
└── {adminDoc}/ [Document]
├── 01ListOfAdmin: array
│ ├── 0: "admin@gmail.com"
│ └── 1: "admin2@gmail.com"
│
├── broadcast: map {
│ ├── msg: array [
│ │ 0: map {
│ │ icon: "💳"
│ │ message: "Friendly reminder: Your water bill payment is due in 3 days."
│ │ timestamp: "2025-04-07T19:13:13.088Z"
│ │ }
│ │ ]
│ └── timestamp: "2025-04-08T00:46:29.000Z" (April 8, 2025 at 12:46:29 AM UTC+5:30)
│ }
├── limit: map {
│ ├── max: number
│ ├── penalty: number
│ └── regular: number
│ }
│
├── price: map {
│ ├── penaltyPrice: number
│ └── regularPrice: number
│ }
│
smsQueue/ [Collection]
└── sms_ab_202511091059382/ [Document]
├── attempts: 0
├── createdAt: "2025-11-09T10:59:38.258Z"
├── message: "Dear Akash Bera, addon of 80L purchased for Rs.50. Payment ID: pay_Rdck9DTiXfX5vm. Your water supply continues uninterrupted."
├── messageType: "addon"
├── metadata: {
│ amount: 50,
│ forMonth: null,
│ paymentId: "pay_Rdck9DTiXfX5vm",
│ refillAmount: 80,
│ mobileNo: "9876543210",
│ referenceId: "users/ab@gmail.com/monthlyUsages/2025-11/addon/addon_details"
│ }
├── sentAt: "November 9, 2025 at 10:35:06 PM UTC+5:30"
├── status: "sent"
└── userId: "ab@gmail.com"
- Clone repository:
git clone https://github.com/your-username/water-management-system.git
cd water-management-system- Configure Firebase:
// src/firebase/config.js
const firebaseConfig = {
apiKey: "YOUR_API_KEY",
authDomain: "PROJECT_ID.firebaseapp.com",
projectId: "PROJECT_ID",
storageBucket: "PROJECT_ID.appspot.com",
messagingSenderId: "SENDER_ID",
appId: "APP_ID"
};- Install dependencies:
npm install
cd functions && npm install-
Data Acquisition
- Flow sensors capture real-time usage data
- ESP32 processes readings at 1Hz sampling rate
-
Edge Processing
- Local storage maintains last-known states (servo position/usage limits)
- Offline mode uses cached values when internet unavailable
-
Time Synchronization
- Daily NTP server sync ensures accurate timestamps
- Midnight flush of daily usage to Firestore
-
F -->|No| H[Maintain State]
-
Data Synchronization
- Periodic Firebase sync (15min intervals)
- Conflict resolution prioritizes cloud data
-
Payment Handling
- Razorpay integration triggers Firestore updates
- Successful payments increment usage limits
MIT License - See LICENSE for details.
pub sub sytstem for the message system (we have to add this in the readme file )
Classic Pub/Sub Pattern: Publisher → Message Queue → Subscriber(s) ↓ ↓ ↓ Payment smsQueue ESP32 System (Firebase) (Worker)
Your System: Payment Event → smsQueue Collection → ESP32 reads & sends SMS (Publisher) (Message Queue) (Subscriber/Consumer)
