Features Architecture Pipeline Stack Team GitHub Repo
Active Academic Project · Dept. Computer Engineering · University of Peradeniya
IoT · Aquaculture · Automation · Real-Time

G.U.A.R.D Logo G.U.A.R.D General Unit for Aquatic Risk Detection

Enterprise-grade aquaculture monitoring for commercial ornamental fish shops and multi-tank hatcheries — replacing slow manual water testing with continuous sensor telemetry and instant alerts.

  • Real-time water quality telemetry via ESP32 nodes over MQTT to HiveMQ Cloud
  • Multi-channel alerting — WebSocket toast, SMTP email & Telegram Bot simultaneously
  • Glassmorphic React dashboard with RBAC, species knowledge base & guided onboarding
System Overview
ESP32MQTT Node.jsReact 19 MongoDBInfluxDB socket.ioTailwind CSS
Hardware NodesESP32 DevKit C (Per Tank)
Sensor SuiteTemp • pH • TDS • Turbidity • Water Level
Telemetry ProtocolMQTT / TLS (1883 / 8883)
Real-Time PushWebSocket (socket.io)
Alert ChannelsEmail · Telegram Bot
SecurityJWT + bcrypt · 3-Tier RBAC
UI ThemesMilky Frost / Obsidian Glow
Scroll
Real-Time Telemetry • Zero Delay

Aquarium Tank Telemetry Deck

Each ESP32 node publishes a JSON payload to HiveMQ Cloud MQTT every 30 seconds. The backend authenticates with bcrypt, stores state in MongoDB, and writes time-series data to InfluxDB simultaneously.

Live Telemetry Feed

Display Tank 01

ONLINE
Last sync: Just now
Temperature
28.4 °C
pH Level
7.21 pH
TDS
430 ppm
Turbidity
12 NTU
Water Level
82 %
Automated Actuator Controls
Last Action: PUMP_AUTO @ Sync
Fish Feeder
PWM Servo Motor
Water Pump System
5V Relay (Inflow/Outflow)
All 5 parameters & actuators operational for Discus Hatchery preset
MQTT Broker: HiveMQ Cloud (TLS)
Sensor Hardware Specifications
  • Temperature:
    DS18B20 waterproof digital sensor (OneWire)
  • pH Level:
    Gravity pH-4502C Probe (6.5–8.5 safe range)
  • Water Level:
    JSN-SR04T ultrasonic sensor (non-contact)
  • Turbidity:
    Optical TSS light-scattering sensor (50 NTU max)
  • TDS:
    Analog probe with temperature-compensated firmware
  • Automated Fish Feeder:
    PWM Micro Servo Motor (Precision timed feed dispense)
  • Water Inflow & Outflow Pumps:
    4-Channel 5V Relay Module (AUTO / ON / OFF modes)
MQTT Payload Structure (ESP32 → HiveMQ Cloud)
// MQTT Topic: guard/telemetry/GUARD-D01
{
  "device_id": "GUARD-D01",
  "ph": 7.2,
  "temperature": 28.4,
  "tds": 430,
  "turbidity": 12,
  "water_level": 82
}
Core Capabilities

Six Reasons G.U.A.R.D Stands Apart

Purpose-built for aquaculture — every feature answers a real-world problem that costs fish health and money.

Five-Parameter Sensor Fusion

Simultaneous real-time measurement of Temperature, pH, TDS, Turbidity, and Water Level via SVG arc gauges — zero polling lag with WebSocket push every 30-second telemetry cycle.

Dual-Channel Instant Alerting

Threshold breaches trigger simultaneous SMTP email and Telegram Bot notifications — with in-memory throttling to prevent duplicate alert floods.

Automated Actuator Controls

Remote & threshold-driven relay pump switching (AUTO / ON / OFF) and PWM micro-servo feeder dispatching over MQTT to maintain optimal tank conditions.

Fish Species Knowledge Base

20 research-verified freshwater species with optimal pH, Temp, TDS, and Turbidity ranges. Tank Compatibility Checker cross-validates threshold configs in real time.

Guided Onboarding Tour

First-time users never see an empty dashboard — auto-routed to a /demo sandbox with a driver.js step-by-step tour across 7 (USER) or 11 (ADMIN) highlights.

Enterprise Security Layer

Three-tier RBAC (SUPER_ADMIN / ADMIN / USER), bcrypt device secrets, JWT-protected REST, duplicate-alert suppression, and offline threshold sync via MQTT retained messages.

Alert Queue · Tank 3
TEMP_HIGH — 34.1°C exceeds 32°C max
Notified via Email + Telegram
12:34
PH_LOW — 6.1 below 6.5 threshold
Toast notification sent
11:58
✅ TURBIDITY_HIGH — Resolved
Marked resolved by Admin
10:22
🤖 @GUARD_yp_bot — Telegram verification active
Alert Engine

Never miss a critical event.

The rule-based alert engine checks every telemetry payload against per-device configurable thresholds. On a breach with no existing unresolved duplicate, an Alert record is persisted and dispatched across all channels simultaneously.

  • SMTP email delivery to tank owner on threshold breach
  • Instant Telegram Bot message via @GUARD_yp_bot
  • Per-account email / Telegram enable toggles
  • In-memory throttling prevents alert flood storms
System Architecture

End-to-End IoT Architecture

From ESP32 edge nodes to React dashboard — every layer purpose-built for low-latency aquatic telemetry.

IoT Node(s)
Sensors & Actuators (Multiple Nodes Possible)
Data (Pub)
Commands (Sub)
MQTT Message Broker
MQTT Broker Pub / Sub
Process Data /
Commands
Central Application Server
Data Processing
Alert Engine
Control Logic
Status / Control
(REST / WebSocket)
User Interface (Dashboard)
Status & Control
Archive & Log
Database Cluster
TimeSeries
(InfluxDB style)
Store Data
Document
(MongoDB style)
Store State
Deployment Ports
Backend  → :5000  REST + WebSocket
Frontend → :5173  Vite dev server
MongoDB  → :27017 Primary state DB
InfluxDB → :8086  Time-series
MQTT    → :1883/:8883 HiveMQ Cloud
ESP32 GPIO Pinout
GPIO 4   → DS18B20 Temperature (OneWire)
GPIO 34  → pH-4502C Probe (ADC)
GPIO 35  → TDS Sensor (ADC)
GPIO 36  → Turbidity Sensor (ADC)
GPIO 13/12 → JSN-SR04T Trig / Echo
Operational Pipeline

7-Step Data Journey

From sensor voltage to dashboard update — every stage in the real-time telemetry pipeline explained.

1
aquamonitor/devices/<uid>/data
ESP32 Telemetry Acquisition & Actuator Listener

ESP32 reads 5 water quality sensors (DS18B20 Temp, pH, TDS, Turbidity, Ultrasonic Level) every 30s and publishes TLS-encrypted JSON payloads to HiveMQ Cloud while listening on control topics for actuator commands.

2
MQTT Client Ingestion
Backend Ingestion & Device Authentication

Node.js MQTT client ingests incoming telemetry from HiveMQ Cloud, verifies device UID against MongoDB, and authenticates device secret via bcrypt. Unauthorized or corrupt payloads are safely discarded.

3
Prisma ORM + InfluxDB Write
Dual-Database Persistence

Latest tank state & device status are updated in MongoDB via Prisma ORM, while high-frequency telemetry points are simultaneously written to InfluxDB time-series storage for analytics.

4
Alert Engine & Actuator Control
Rule Evaluation & Automated Actuation

Alert engine checks configurable thresholds per species. Breaches trigger alert persistence, duplicate suppression, and automated actuator commands (water pump relay switching & fish feeder servo dispensing).

5
WebSocket · SMTP · Telegram
Multi-Channel Alert Dispatch

Alerts are dispatched simultaneously via socket.io to connected frontend clients (toast & badge), SMTP email to tank owners, and instant Telegram Bot messages (@GUARD_yp_bot).

6
React + socket.io-client
React Dashboard Real-Time Telemetry

Frontend UI subscribes to real-time WebSocket events. SVG arc gauges re-render live stats, actuator toggle states update instantly, and alert indicators increment — with zero page polling.

7
InfluxDB → Recharts
Historical Analytics & Species Checker

JWT-authenticated REST APIs query InfluxDB time-series data to render interactive Recharts trend graphs, allowing users to analyze historical parameter stability against species thresholds.

Pragmatics

Tech Stack & Bill of Materials

Frontend
React 19 Vite 7.x Tailwind CSS v3.4 React Router v6 Recharts 2.x socket.io-client 4.x driver.js 1.x Axios
Backend
Node.js 22 LTS Express 4.x Prisma 6.x MongoDB 7+ InfluxDB 2.x MQTT.js 5.x socket.io 4.x bcrypt + JWT
Firmware (ESP32)
Arduino Framework PubSubClient MQTT ArduinoJson OneWire + DallasTemp WiFi.h Preferences NVS
Infrastructure
HiveMQ Cloud Docker + Compose GitHub Pages Nodemailer SMTP Telegram Bot API

Default Alert Threshold Configuration

Alert TypeConditionSensor
TEMP_HIGHtemperature > TEMP_MAXTemperature
TEMP_LOWtemperature < TEMP_MINTemperature
PH_HIGHph > PH_MAXpH Level
PH_LOWph < PH_MINpH Level
TDS_HIGHtds > TDS_MAXTDS
TURBIDITY_HIGHturbidity > TURBIDITY_MAXTurbidity
WATER_LEVEL_LOWwater_level < WATER_LEVEL_MINWater Level

Bill of Materials — Per-Tank Hardware Node

ComponentModel / SpecInterfaceQtyEst. Cost
MicrocontrollerESP32 DevKit CWi-Fi, GPIO1LKR 4,000
Temperature SensorDS18B20 WaterproofOneWire GPIO 41LKR 800
pH Sensor ModulepH-4502C / Gravity pHAnalog ADC1LKR 5,000
ORP Sensor ModuleORP Probe + ConditionerAnalog ADC1LKR 6,000
TDS SensorAnalog TDS ModuleAnalog ADC1LKR 2,500
Turbidity SensorOptical TSS ModuleAnalog ADC1
Water Level SensorJSN-SR04T UltrasonicDigital Trig/Echo1LKR 600
EC SensorEC ModuleAnalog ADC1LKR 6,500
Relay Module4-Channel 5V RelayDigital GPIO1LKR 1,200
Power Supply12V DC + LM2596 BuckVIN / GND1LKR 3,000
MiscellaneousPCB, jumpers, casing, fuseLKR 2,000
Estimated Total (Per Node)~LKR 31,600
Engineering Team

3yp - Team 08 : E21

Third Year Software Engineering Project · Department of Computer Engineering · Faculty of Engineering · University of Peradeniya

Ravindu Ashan
Ravindu Ashan
E/21/039
View Profile →
Asindu Chandasekara
Asindu Chandasekara
E/21/067
View Profile →
Thisen Lakdinu
Thisen Lakdinu
E/21/231
View Profile →
Shashika Sathsarani
Shashika Sathsarani
E/21/362
View Profile →
Project Supervisor
Y
Academic Supervisor
Ms. Yasodha Vimukthi
Department of Computer Engineering
University of Peradeniya
yasodhav@eng.pdn.ac.lk View Profile →
University of Peradeniya
Faculty of Engineering
Department of Computer Engineering
3rd Year Project