⚡ Campus Energy Monitor

Cloud Dashboard • Cloudflare Pages • CPUT Final Year Project

MQTT Connecting...
ESP32 Waiting...
🌏 Cloud • --
⚠ MQTT not connected. Fill in your HiveMQ credentials in Settings tab, then refresh.
🌡 Temperature
--°C
DS18B20
🌀 Fan Speed
--%
--
💡 PIR / Light
--%
PIR: --
⚡ Total Power
-- W
PZEM L1+L2+L3
Phase L1
-- V
-- W
Phase L2
-- V
-- W
Phase L3
-- V
-- W
--°C
🌡 Temperature
0°C60°C
--%
🌀 Fan Speed
0%100%
-- W
⚡ Total Power
0 W3 kW
--
📊 Power Factor
01.0
🖶 LCD Display (live from ESP32)
== ENERGY MONITOR ==
Tmp: --.- C Fan: 0%
PIR:Idle WiFi:--
Waiting for MQTT...

🌏 Commands sent via MQTT → HiveMQ Cloud → ESP32 in lab. Response within ~1 second.

🌀 Fan Control

Speed: --% • Mode: --

💡 Enclosure Light

Brightness: --% • PIR: --

🔦 IR LED (GPIO 32)

State: --

🔔 Buzzer (GPIO 27)

Beep count (1–5)

⬛ Emergency

Turn everything off

📷 IR Remote Reference (NEC remote, GPIO 14 — hardware-side only)

Fan Speed
1 → Fan OFF  |  2 → 30%
3 → 60%  |  4 → 100%
5 → AUTO (temp-based)
Light
VOL+ → Light ON (full)
VOL- → Light OFF
LED (GPIO 32)
100+ → LED ON
200+ → LED OFF
Buzzer
CH+ → Beep 1×
CH  → Beep 2×
CH- → Buzzer stop
Other
0  → ALL OFF
PREV → Force temp read
EQ  → Force PZEM read
Physical fan button (GPIO 19) cycles: OFF → 30% → 60% → 100% → OFF

⚡ Phase L1 (0x01) N/A

Voltage--
Current--
Power--
Power Factor--
Frequency--
Energy--

⚡ Phase L2 (0x02) N/A

Voltage--
Current--
Power--
Power Factor--
Frequency--
Energy--

⚡ Phase L3 (0x03) N/A

Voltage--
Current--
Power--
Power Factor--
Frequency--
Energy--

📈 Cloud Data Platforms

📈
Grafana Cloud
Historical dashboard
▶ Last 1 Hour ▶ Last 24 Hours ▶ Last 7 Days
📄
Google Sheets & Tableau
Spreadsheet & visual analytics
📄 Google Sheets (Data) ⎈ Apps Script Webhook 📈 Tableau Dashboard

📊 ThingSpeak — Historical Trends

Data from ThingSpeak Ch-A (Voltage/Current/Power) & Ch-B (PF/Freq/kWh). 6 charts — 15 s updates from ESP32.

📱 MQTT Connection (HiveMQ Cloud)

From HiveMQ Cloud dashboard — do NOT include wss:// or port

📈 Grafana

Use the public share link from your Grafana dashboard

🧠 AI Brain — Keys & Fallback

Free 15 req/min per key — aistudio.google.com. Keys rotate automatically on 429 errors.
platform.deepseek.com — very cheap ($0.07/M tokens). Used as last resort.
Active: Gemini key 1/4 — fallback: DeepSeek

🎤 AI Voice Settings

Auto-fallback chain (best → last resort):
🌟 ElevenLabs → ☁ Azure → ⭐ StreamElements → 🔊 VoiceRSS → 🌐 Browser
Free 10K chars/month — elevenlabs.io → Developers → copy key.
Applies to StreamElements, VoiceRSS and Browser. ElevenLabs uses its own pacing.

⚠ Danger Zone

Reset all dashboard configuration to factory defaults. Clears API keys, MQTT credentials, TTS settings, Personalize/schedule settings, and chat history. The page will reload.

💡 PIR Motion Light

Light stays ON this long after motion stops (1 – 120 seconds). Sent to ESP32 via MQTT.
PWM brightness level the enclosure light fades up to on motion (10 – 100%).

🌀 Fan Temperature Thresholds

°C
°C
°C
°C
OFF → 30% at 28°C → 60% at 32°C → 100% at 36°C → 💥 CRITICAL at 40°C

⏰ LED Light Scheduler

Enable LED schedule
⚠ Scheduler runs only while this browser tab is open — it sends MQTT commands at the set times.

📷 Camera — TTGO OV2640

Auto-flash LED on snapshot
GPIO 32 LED fires before each snapshot as light source, turns off when image received
PIR auto-snap on motion
Enables PIR on the TTGO on page load. Snaps on motion (30 s cooldown in firmware).
Rapid snapshot mode
Auto-snap at fixed interval while camera is ON (pseudo-stream)
Every
⚠ Keep rapid mode OFF when not needed — increases TTGO heat and HiveMQ traffic.

📧 Email Reports

Enable scheduled reports
Report includes: temperature, fan, PIR, power (L1/L2/L3), LED state, uptime.

🔔 System Alerts

🌡 Temperature
Enable alert
Trigger above °C
⚡ Total Power
Enable alert
Trigger above W
🔌 MQTT Connection
Alert on disconnect
Shows toast when MQTT drops
📧 Alert Delivery
Email on alert
Uses address from Email Reports above
↻ Reset Personalize to Defaults
Resets all schedule, alert, PIR, fan threshold, camera and email settings to factory defaults.

🤖 AI Energy Assistant

preview

ESP32: /fan off • /fan low • /fan med • /fan high • /fan auto • /light on • /light off • /led on • /led off • /beep • /all off   |   Camera: /cam on • /cam off • /cam snap • /pir on • /pir off

ℹ About This System

Campus Energy Monitor is an ESP32-based 3-phase energy monitoring system built as a CPUT Final Year Project. It delivers real-time energy data via MQTT, full remote hardware control, and an AI assistant with live sensor context — all accessible from anywhere in the world through this cloud dashboard.

Key Features

  • 3-Phase Energy Metering — PZEM-004T on L1, L2, L3 (voltage, current, power, PF, frequency, kWh)
  • Temperature Monitoring — DS18B20 with automatic PWM fan control (4 threshold levels)
  • Remote Fan / Light / LED / Buzzer control via MQTT command topics
  • PIR Motion-activated enclosure light — HC-SR501 with brightness fade
  • Real-time MQTT sync — HiveMQ Cloud broker, sensor state published every 5 seconds
  • AI Energy Assistant — Gemini 2.5 Flash with live MQTT sensor context in system prompt
  • AI Voice Call — full-duplex conversation, continuous speech recognition + TTS
  • AI Video Call — camera feed with automatic frame analysis every 30 seconds
  • Multi-provider TTS — Browser, Azure Neural, ElevenLabs, VoiceRSS (configurable in Settings)
  • Slash commands routed via MQTT: /fan off /fan auto /light on /led off /beep /all off
  • Grafana Cloud tab — embed historical charts and alerts dashboard
  • Cloudflare Pages — global HTTPS, zero cold-start, custom domain ready
ESP32-WROOM-32U PZEM-004T x3 DS18B20 HiveMQ Cloud Gemini 2.5 Flash Cloudflare Pages CPUT Final Year 2026
Developer
Henock HNK
Henock HNK
Computer Engineer

Computer Engineer specializing in software development, scientific computing, networking, electronics, and embedded systems with extensive experience in technical tutoring. I believe technology should solve real problems. My journey across tech — from electronics and industrial to computer engineering — taught me that the best solutions come from curiosity, persistence, and the courage to take unconventional paths.

Today I bridge hardware and software, turning ideas into working systems — from IoT devices monitoring energy consumption to web applications solving client challenges. I also teach, because sharing knowledge deepens understanding. When a student grasps a complex concept, that is engineering success too.

CPUT Final Year 2026 Supervisor: M. Ratshitanga Student No: 219383693

📷 Lab Camera — TTGO OV2640

Points at PZEM-004T open-CT connections • MQTT snapshot on demand
Camera offline
⚡ Rapid Snap
Auto-snap continuously — starts camera automatically
⚠ Keep camera OFF when not needed — reduces heat and extends lifespan over long experiments.

💡 Lab LED — GPIO 32

OFF
Auto-flash on snapshot
LED fires briefly before each snapshot as light source, turns off when image received

⏱ Auto Snapshot

Auto snapshot every
Camera must be ON for auto-snapshot to work. Scheduler runs while this browser tab is open.

🎦 Last Snapshot

No snapshot yet
📷
Turn camera ON then press Take Snapshot

📧 Send a Message

📌 Get In Touch

Institution
Cape Peninsula University of Technology (CPUT)
Supervisor: M. Ratshitanga • Student No: 219383693
Location
🇨🇦 Cape Town, South Africa
🤖
Energy AI
Connecting...
00:00
📷 Analyzing...
Connecting...
00:00
🎤 Listening...
Speaking...

⚙ AI Voice Settings

Active Provider
Browser (Web Speech)
Change provider & API keys in the Settings tab.