AI-powered smart energy meter for Egyptian homes: ESP32 telemetry over MQTT, LightGBM month-end bill forecasting on Egypt's progressive tariff, and budget-aware appliance recommendations.
# Smart Energy Meter — IoT + AI
Real-time household electricity monitoring with month-end bill prediction, Egypt
tiered-tariff costing, and budget-aware appliance recommendations.
**Competition track:** Intelligent Systems and AI (primary) + Internet of Things (supporting)
> **Hardware status.** The ESP32 and its sensors are on order and not yet in hand,
> so no firmware is in this repository. Everything below runs today against
> `backend/scripts/mock_esp32.py`, which publishes over the same MQTT topic and
> the same JSON contract the real meter will use, so the device is the only
> component that changes when the hardware arrives. See SUBMISSION_STATUS.md §12.
---
## What it does
An ESP32 with current/voltage sensors measures household power draw and publishes
telemetry over MQTT — today that publisher is the simulator, pending hardware. A
FastAPI backend ingests it into PostgreSQL, rolls it up into hourly and daily
aggregates, and uses that history to:
1. **Predict the month-end bill** — a LightGBM model, benchmarked against a naive
extrapolation baseline with honestly reported error (see *Model performance*).
2. **Cost it in EGP** — a progressive Egyptian residential tariff engine, with an
inverse function that converts a target bill back into an allowed kWh figure.
3. **Recommend appliance usage** — a greedy allocator that keeps you inside a daily
budget while never restricting appliances marked essential.
A Next.js frontend presents this as three screens: **Overview** (live power → predicted
bill with its confidence range → what to do about it), **Budget Planner** (a target
bill in, the kWh it allows out), and **Recommendations** (today's per-appliance plan,
with essential appliances shown locked).
---
## Architecture
```
ESP32 + SCT-013 / ZMPT101B scripts/mock_esp32.py
(voltage, current, power) (simulator, no hardware needed)
│ │
└──────────► MQTT ◄────────────────┘
home/+/telemetry
│
app/workers …