Back to Projects

Smart Water Monitoring

Raspberry Pi + IoT sensors for real-time usage tracking and anomaly detection.

Raspberry PiPythonMQTTInfluxDBGrafana

Live Monitoring (Simulated)

Flow Rates (L/min)LIVE
2.5
Main Line
0.0
Shower
0.0
Outdoor
Today's Usage
152.3 liters
0 LTarget: 200 L/day

Edge-to-Cloud Architecture

Edge Layer
YF-S201 SensorsGPIO InterruptsPulse Counter
Gateway (Pi)
Python DaemonSQLite CacheAnomaly Detection
Cloud
MQTT BrokerInfluxDBGrafana
SensorsPi HubMQTTDashboard

Anomaly Detection

Z-Score Based Detection

7-day rolling baseline per hour. Alerts when flow > 2σ from expected.

z = (current - μ) / σ
anomaly = |z| > 2.0

Continuous flow > 30 min triggers leak alert via Pushover API.

Data Pipeline

1
Pulse Detection
Hall-effect sensor generates pulses (~4.5 per mL)
2
GPIO Interrupt
Pi captures rising edges with µs timestamps
3
Flow Calculation
Pulses/sec × calibration → L/min
4
Local Storage
SQLite buffer for offline resilience
5
MQTT Publish
60-second aggregates to cloud broker

Design Decisions

MQTT over HTTP
Lightweight protocol with built-in QoS, persistent sessions, and 99.8% bandwidth reduction vs raw telemetry.
Edge Analytics
Anomaly detection on Pi enables offline alerting and reduces cloud dependency.
Per-Sensor Calibration
Factory calibration varied 5-12%. Field calibration improved accuracy from ±10% to ±2%.
SQLite Buffer
30-day local history prevents data loss during outages, enables offline queries.
±2%
Sensor Accuracy
60s
Cloud Sync Interval
30min
Leak Alert Threshold
15-30%
Potential Savings
IoT water monitoring for residential conservation