A comprehensive power consumption monitoring system that measures voltage, current, instantaneous power, and energy consumption in real-time using ESP32 microcontroller and sensor modules.
- Overview
- Features
- Components Required
- Hardware Setup
- Software Setup
- Circuit Diagram
- Code Explanation
- Assembly Instructions
- Calibration Process
- Usage
- Troubleshooting
- Contributing
- License
This project creates a smart power consumption monitoring device that can be inserted between any AC appliance and wall socket to measure real-time energy consumption. The device displays voltage, current, instantaneous power, and cumulative energy consumption on an OLED display, cycling through different screens automatically.
Original Tutorial: DIY Real-Time Energy Monitoring Device using ESP32
- Real-time monitoring of voltage, current, and power consumption
- Multi-screen display showing different parameters
- Energy consumption tracking with units calculation
- Automatic screen switching every 5 seconds
- Calibration support for accurate readings
- Compact design with 3D printed enclosure
- Safe isolation up to 4000V with ZMPT101B sensor
Component | Quantity | Description |
---|---|---|
ESP32 WROOM 32D Module | 1 | Main microcontroller |
HI LINK 5V 3W SMPS | 1 | Power supply module |
0.96" 128X64 I2C OLED Display | 1 | Display unit |
ZMPT101B Voltage Sensor | 1 | AC voltage measurement |
ACS712 20A Current Sensor | 1 | Current measurement |
220V AC 3 Pin Socket (Male) | 1 | Input connection |
220V AC 3 Pin Socket (Female) | 1 | Output connection |
3D Printed Casing | 1 | Protective enclosure |
ESP32 Pin | Component | Connection |
---|---|---|
Pin 34 | ZMPT101B | Analog Output |
Pin 36 (VP) | ACS712 | Analog Output |
Pin 21 (SDA) | OLED Display | I2C Data |
Pin 22 (SCL) | OLED Display | I2C Clock |
5V | All Components | Power Supply |
GND | All Components | Ground |
- HI-Link SMPS: Connected in parallel with AC Live and Neutral
- ZMPT101B: Input terminals connected in parallel with AC supply
- ACS712: Connected in series with AC Live wire
- All components: Powered by 5V output from HI-Link module
Install the following libraries through Arduino IDE Library Manager:
- Adafruit GFX Library
- Adafruit SSD1306 Library
- ZMPT101B Library (Custom - download from GitHub)
- ACS712 Library (Custom - download from GitHub)
- Open Arduino IDE
- Go to Tools → Library Manager
- Search and install Adafruit libraries
- For custom libraries:
- Download ZIP files from GitHub repositories
- Go to Sketch → Include Library → Add .ZIP Library
- Select downloaded ZIP files
#include "ZMPT101B.h"
#include "ACS712.h"
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
AC Live ──┬─── ZMPT101B Input ─── ESP32 Pin 34
│
└─── ACS712 Input ────── ACS712 Output ─── Load
AC Neutral ─── ZMPT101B Input ─── Load
HI-Link SMPS:
AC Live/Neutral ─── Input
5V/GND ─── ESP32 & Sensors Power
I2C OLED:
SDA ─── ESP32 Pin 21
SCL ─── ESP32 Pin 22
setup()
: Initializes sensors, display, and calibrationloop()
: Main execution loop for data acquisition and displaydisplayVoltCurrent()
: Shows voltage and current readingsdisplayInstPower()
: Shows instantaneous power consumptiondisplayEnergy()
: Shows cumulative energy consumptiondisplayUnits()
: Shows energy units consumedCalibCurrent()
: Calibrates current sensor zero pointCalibVoltage()
: Calibrates voltage sensor zero point
The device cycles through 4 different screens:
- Voltage & Current (V and A)
- Instantaneous Power (W or kW)
- Energy Consumption (Wh, kWh, etc.)
- Units Consumed (Based on energy consumption)
- 3D Print the enclosure using provided STL files
- Solder all connections according to the circuit diagram
- Test the circuit on breadboard before final assembly
- Use heat shrink and insulation tape for safety
- Fit components into the 3D printed casing
- Secure all connections and close the enclosure
Before first use, calibrate both sensors:
-
Uncomment calibration functions in setup():
//CalibCurrent(); //CalibVoltage();
-
Upload code with one calibration function active at a time
-
Ensure no voltage/current is present during calibration
-
Note the zero point values displayed
-
Update zero points in the code:
voltageSensor.setZeroPoint(2621); // Update this value currentSensor.setZeroPoint(2943); // Update this value
-
Comment out calibration functions and upload final code
- Connect the device between wall socket and appliance
- Power on - the device will start automatically
- View readings on the OLED display
- Screens change automatically every 5 seconds
- Monitor real-time energy consumption
- Voltage: AC voltage in Volts (V)
- Current: AC current in Amperes (A)
- Power: Instantaneous power in Watts (W) or Kilowatts (kW)
- Energy: Cumulative energy in Wh, kWh, etc.
- Units: Energy consumption units for billing
- Display not working: Check I2C connections and address (0x3C)
- Incorrect readings: Perform sensor calibration
- No power: Verify HI-Link SMPS connections
- Sensor noise: Check grounding and shielding
The code includes threshold values to filter noise:
- Voltage threshold: 55V (below this, voltage = 0)
- Current threshold: 0.15A (below this, current = 0)
These can be adjusted based on your specific requirements.
- Use proper insulation and enclosure
- Test thoroughly before use
- Ensure proper grounding
- Use appropriate fuses and protection
- Follow local electrical codes
Feel free to contribute to this project by:
- Reporting bugs
- Suggesting improvements
- Adding new features
- Improving documentation
This project is open-source and available under the MIT License.
Project Source: CircuitDigest - DIY Real-Time Energy Monitoring Device
Disclaimer: This project is for educational purposes. Use at your own risk and ensure compliance with local electrical regulations.