AquaMonitor is a backend service for a water-tank monitoring system. It ingests sensor data (temperature, level, turbidity, TDS, ambient conditions) from IoT devices via MQTT, serves a web dashboard, and provides real-time updates over WebSocket (Socket.IO).
- Real-time data streaming to a web dashboard (Socket.IO)
- MQTT ingestion (HiveMQ Cloud compatible)
- Last N historical readings stored per sensor
- Alerts for out-of-range values and tank integrity checks
- Individual sensor pages with trends and tables
| Sensor | Parameter | Purpose |
|---|---|---|
| DS18B20 | Water temperature | Detect unsafe water temperatures |
| HC-SR04 | Water level | Prevent overflow / low-level conditions |
| Turbidity sensor | Water clarity | Detect contamination/sediment |
| TDS sensor | Dissolved solids | Assess water purity |
| DHT11 | Ambient temp & humidity | External environment monitoring |
- Node.js + Express
- Socket.IO for real-time client updates
- MQTT (HiveMQ Cloud) for device telemetry
- Chart.js on the frontend for visualizations
- Arduino (UNO) and NodeMCU (ESP8266) for sensor collection and MQTT bridge
- Deployment target: Render
Prerequisites
- Node.js 18 or later
- Arduino IDE (for firmware)
- HiveMQ Cloud account (or other MQTT broker)
- Git
Clone and install
git clone https://github.com/AdityaGupta0001/aquamonitor.git
cd aquamonitor/backend
npm installConfigure environment variables
Create a .env file in the backend directory:
MQTT_HOST=your-hivemq-cluster.s1.eu.hivemq.cloud
MQTT_PORT=1883
MQTT_PROTOCOL=mqtt
MQTT_USERNAME=your-username
MQTT_PASSWORD=your-password
PORT=3000Upload Arduino code
- Open
arduino/sensor_reader.inoin Arduino IDE - Update sensor pin configurations if needed
- Upload to Arduino UNO
Upload NodeMCU code
- Open
nodemcu/mqtt_bridge.inoin Arduino IDE - Update WiFi credentials:
const char* ssid = "Your_WiFi_Name"; const char* password = "Your_WiFi_Password";
- Update HiveMQ credentials:
const char* mqtt_server = "your-cluster.hivemq.cloud"; const char* mqtt_user = "your-username"; const char* mqtt_password = "your-password";
- Upload to NodeMCU ESP8266
Run locally
npm startVisit http://localhost:3000 to view the dashboard.
Deploy to Render
- Push code to GitHub
- Create a new Web Service on Render
- Connect your repository
- Add environment variables
- Deploy!
Accessing the dashboard
- Landing Page:
https://aquamonitor.onrender.com/ - Main Dashboard:
https://aquamonitor.onrender.com/dashboard - Individual Sensors:
/sensor/temperature,/sensor/distance,/sensor/turbidity,/sensor/tds,/sensor/environment
Configuration
Adjust thresholds in server.js:
const config = {
tankTotalVolume: 1000, // Tank capacity in liters
distanceFull: 1, // Distance when tank is full (cm)
distanceEmpty: 100, // Distance when tank is empty (cm)
turbidityThreshold: 1000, // Max turbidity (NTU)
tdsMin: 50, // Min TDS (ppm)
tdsMax: 300, // Max TDS (ppm)
tempMin: 15, // Min water temp (°C)
tempMax: 30, // Max water temp (°C)
outsideTempMax: 45 // Max outside temp (°C)
};Main Dashboard
- Overview of all 5 sensors
- Real-time animated visualizations
- Status indicators for each parameter
- Alert notifications
Individual Sensor Pages Each sensor has a dedicated page with:
- Current readings with visual widgets
- Trend graphs (last 50 readings)
- Historical data table (last 200 readings)
- Technical specifications
- Working principles
- Pin connection diagrams
Smart Alerts Automatic pop-up notifications when:
- Water level drops below 20%
- Temperature exceeds safe range
- Turbidity indicates contamination
- TDS levels are unsafe
- Tank integrity is compromised
NodeMCU Not Connecting to HiveMQ
- Verify WiFi credentials
- Check HiveMQ username/password
- Ensure port 1883 is accessible
- Check Serial Monitor for error codes
Dashboard Not Receiving Data
- Check Render logs for MQTT connection status
- Verify HiveMQ credentials in environment variables
- Test MQTT connection using HiveMQ Web Client
- Ensure NodeMCU is publishing to
sensor/datatopic
Sensor Readings Incorrect
- Calibrate sensors individually
- Check wiring connections
- Verify Arduino serial output
- Adjust sensor-specific configurations
| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Landing page |
/dashboard |
GET | Main dashboard |
/sensor/:type |
GET | Individual sensor page |
/api/latest |
GET | Latest sensor data (JSON) |
/health |
GET | Health check status |
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
Your Name
- GitHub: @AdityaGupta0001
- Project Link: https://github.com/AdityaGupta0001/AquaMonitor
- HiveMQ Cloud for free MQTT broker
- Render for hosting platform
- Chart.js for beautiful visualizations
- ESP8266 community for excellent documentation
Built with ❤️ for smart water management