How patric1304/water-quality-iot-project works
The product is an IoT water-quality monitoring system. Its primary workflow samples pH, TDS, turbidity, and temperature on a Raspberry Pi, publishes readings through AWS IoT Core and Lambda, stores and analyzes them in Django, then serves a dashboard and alert history. The ML branch trains an LSTM autoencoder and uses its exported model for inference; Lambda also applies the documented alert decision matrix and can notify through SNS. Relationships for cloud services and unsampled dashboard behavior follow the README; source excerpts provide the Pi, backend, and ML implementation evidence.
Main entry points: views.py Reading API · main.py Reading loop · handler.py Ingestion and alerts · ml_inference.py Anomaly inference
Components 20
Edge sensing
- pH sensor
pi/sensors/ph.py - TDS sensor
pi/sensors/tds.py - Turbidity sensor
pi/sensors/turbidity.py - Temperature sensor
pi/sensors/temperature.py - Reading loop
pi/main.py
Cloud ingestion
- IoT Core
- Ingestion and alerts
lambda/handler.py
Backend monitoring
- Reading API
backend/monitor/views.py - API routes
backend/monitor/urls.py - API key auth
backend/monitor/authentication.py - Reading records
backend/monitor/models.py - Reading serializer
backend/monitor/serializers.py
Anomaly detection
- Anomaly inference
backend/monitor/ml_inference.py - Feature engineering
ml/feature_engineering.py - Model training
ml/train_model.py - Exported model assets
ml/model.onnx
Dashboard and alerts
- Web dashboard
backend/monitor/templates/monitor/dashboard.html - Amazon SNS
Other components
- Water operator
- Email and SMS recipients
Connections 21
- Reading loop → pH sensor: reads
pi/main.py - Reading loop → TDS sensor: reads
pi/main.py - Reading loop → Turbidity sensor: reads
pi/main.py - Reading loop → Temperature sensor: reads
pi/main.py - Reading loop → IoT Core: publishes readings
README.md - IoT Core → Ingestion and alerts: triggers
README.md - Ingestion and alerts → Reading API: posts reading
README.md - API routes → Reading API: routes requests
backend/monitor/urls.py - Reading API → API key auth: checks write access
backend/monitor/views.py - Reading API → Reading serializer: serializes readings
backend/monitor/views.py - Reading API → Reading records: reads and writes
backend/monitor/views.py - Reading API → Anomaly inference: runs inference
backend/monitor/views.py - Anomaly inference → Feature engineering: engineers features
backend/monitor/ml_inference.py - Model training → Feature engineering: engineers training data
ml/train_model.py - Model training → Exported model assets: exports model
- Anomaly inference → Exported model assets: loads model assets
- Ingestion and alerts → Amazon SNS: publishes alerts
README.md - Amazon SNS → Email and SMS recipients: sends notifications
README.md - Water operator → Web dashboard: views status
README.md - Web dashboard → Reading API: requests readings
- Water operator → Reading API: queries reading data
README.md