Build a Smart Energy Monitor
A smart energy monitor measures electrical parameters in real time, allowing homeowners, businesses and engineers to understand how much electricity is being consumed. It can display voltage, current, power, energy usage and power factor while sending the information to a smartphone or computer over Wi-Fi. This project demonstrates how to build a smart energy monitor using an ESP32 and an energy metering module such as the PZEM-004T.
Project Overview
The energy meter continuously measures the electrical parameters of the connected load.
The ESP32 reads the measurements through a serial interface and displays the results on an OLED display or web dashboard.
Energy consumption can be logged for long-term analysis, helping identify high-power appliances and opportunities to reduce electricity usage.
Project Difficulty
| Item | Value |
|---|---|
| Difficulty | ⭐⭐⭐⭐ Advanced |
| Build Time | 5–10 Hours |
| Supply Voltage | 5 V DC (Controller) |
| Measured Voltage | 80–260 V AC (Typical) |
| Controller | ESP32 |
Electrical Parameters Measured
| Parameter | Description |
|---|---|
| Voltage (V) | AC supply voltage. |
| Current (A) | Load current. |
| Power (W) | Instantaneous active power. |
| Energy (kWh) | Total energy consumed. |
| Frequency (Hz) | Mains frequency. |
| Power Factor | Efficiency of AC power usage. |
Main Sections
| Section | Function |
|---|---|
| ESP32 | Processes measurements and provides Wi-Fi connectivity. |
| Energy Meter Module | Measures voltage, current, power and energy. |
| Current Transformer or Shunt | Measures load current. |
| OLED Display (Optional) | Displays measurements locally. |
| Wi-Fi Interface | Uploads data to dashboards or cloud services. |
| MicroSD Module (Optional) | Stores historical measurements. |
Typical Components
| Quantity | Component |
|---|---|
| 1 | ESP32 Development Board |
| 1 | PZEM-004T, ATM90E32 or Similar Energy Meter |
| 1 | Current Transformer (If Required) |
| 1 | OLED Display (Optional) |
| 1 | MicroSD Module (Optional) |
| 1 | 5 V Power Supply |
| 1 | Push Button (Reset/Menu) |
| 1 | Insulated Enclosure |
How the System Works
The energy metering module samples the AC voltage and current of the connected load.
Internal calculations determine the active power, accumulated energy, frequency and power factor.
The ESP32 retrieves these values at regular intervals and displays them on an OLED screen or publishes them via Wi-Fi to a web interface, MQTT broker or home automation system.
Historical data can be stored for daily, weekly or monthly energy analysis.
Typical Features
| Feature | Description |
|---|---|
| Real-Time Measurements | Displays live electrical values. |
| Energy Logging | Stores long-term consumption data. |
| Wi-Fi Dashboard | Remote monitoring from anywhere. |
| Overload Alarm | Warns when current exceeds a preset limit. |
| Daily Statistics | Shows daily and monthly usage. |
| MQTT Support | Integrates with Home Assistant and other IoT platforms. |
Applications
- Home energy monitoring.
- Solar power systems.
- Workshops.
- Industrial equipment.
- Server rooms.
- Energy efficiency studies.
- Smart buildings.
- Electrical laboratories.
Testing
- Verify all mains and low-voltage wiring.
- Power the ESP32 and energy meter.
- Connect a known electrical load.
- Compare voltage and current readings with a calibrated meter.
- Verify power calculations.
- Confirm energy accumulation over time.
- Test Wi-Fi communication.
- Check overload alarm functionality.
Troubleshooting
| Problem | Possible Cause |
|---|---|
| No measurements | Incorrect wiring or communication failure. |
| Incorrect readings | Calibration error or incorrect CT installation. |
| Wi-Fi not connecting | Network configuration issue. |
| Display blank | OLED wiring or power problem. |
| Data not updating | Serial communication fault or software issue. |
Project Improvements
- Support three-phase power measurement.
- Create a web dashboard with historical graphs.
- Send email or Telegram alerts for overload conditions.
- Integrate with Home Assistant using MQTT.
- Store measurements in an SQL database.
- Add OTA firmware updates.
- Generate daily and monthly energy reports.
- Support multiple monitored circuits.
Skills Learned
- AC power measurement.
- Energy metering.
- Serial communication.
- ESP32 programming.
- Wi-Fi networking.
- IoT dashboard development.
Safety Notes
- Extreme care is required when working with mains voltage.
- Disconnect power before wiring or modifying the circuit.
- Use insulated enclosures and correctly rated wiring.
- Install suitable fuses or circuit breakers.
- Verify all measurements with calibrated equipment before relying on the results.
Key Points
- A smart energy monitor provides real-time electrical measurements.
- It helps identify inefficient appliances and reduce electricity consumption.
- ESP32 enables wireless monitoring and cloud connectivity.
- Historical data supports energy management and preventive maintenance.
- Energy monitoring is an important part of modern smart homes and industrial automation systems.