An IoT-based Smart Home Energy Monitoring System that monitors electricity usage in real time and displays energy statistics through a modern web dashboard.
The system collects electrical measurements from an ESP32 and PZEM-004T energy meter and sends the data to a Flask REST API.
The backend stores readings in SQLite and provides APIs to the React dashboard.
The dashboard displays:
- Voltage
- Current
- Power
- Energy consumption
- Electricity cost
- Appliance status
- Alerts
- Power consumption charts
- Monthly energy statistics
Electrical Appliances
│
▼
PZEM-004T Sensor
│
▼
ESP32
│
│ Wi-Fi
▼
Flask REST API
│
▼
SQLite
│
▼
React Dashboard
│
├── Energy Monitoring
├── Appliance Management
├── Charts
├── Cost Calculation
└── Alerts
Technology Stack
Hardware
ESP32
PZEM-004T
AC electrical meter
Wi-Fi
Backend
Python
Flask
Flask-CORS
SQLite
REST API
Frontend
React
Vite
Recharts
JavaScript
CSS
Development Tools
VS Code
PowerShell
Arduino IDE
**Project Structure**
Smart-Home-Energy-Monitoring-System/
│
├── .gitignore
├── .env
├── README.md
│
├── backend/
│ ├── app.py
│ ├── requirements.txt
│ │
│ ├── config/
│ │ ├── __init__.py
│ │ └── config.py
│ │
│ ├── database/
│ │ ├── __init__.py
│ │ └── database.py
│ │
│ ├── models/
│ │ ├── __init__.py
│ │ └── schemas.py
│ │
│ ├── routes/
│ │ ├── __init__.py
│ │ ├── dashboard.py
│ │ ├── readings.py
│ │ ├── appliances.py
│ │ └── alerts.py
│ │
│ └── services/
│ ├── __init__.py
│ └── energy_service.py
│
├── frontend/
│ ├── package.json
│ ├── vite.config.js
│ ├── index.html
│ │
│ └── src/
│ ├── App.jsx
│ ├── main.jsx
│ ├── styles.css
│ │
│ ├── components/
│ │ ├── Header.jsx
│ │ ├── StatCard.jsx
│ │ └── EnergyChart.jsx
│ │
│ ├── pages/
│ │ └── Dashboard.jsx
│ │
│ └── services/
│ └── api.js
│
└── esp32/
└── energy_monitor.ino
Safety
This project may interface with mains electricity through
an energy meter. Mains wiring can cause serious injury or death.
Use properly rated hardware, isolation, enclosure, fusing,
and qualified electrical installation procedures when working
with AC mains.
Future Improvements
Possible upgrades:
User authentication
Email/SMS alerts
Monthly bill prediction
AI-based energy recommendations
Appliance-level energy disaggregation
IoT cloud integration
MQTT support
Mobile application
Historical reports
Solar power monitoring
Smart scheduling