⚡ Smart Energy Meter
Measure real AC mains voltage, current, power, and running energy cost on an LCD.
Overview
This project builds a non-invasive AC energy meter that measures real mains voltage (using a ZMPT101B voltage transformer module) and current (using an ACS712 Hall-effect current sensor) to calculate true RMS power consumption and projected electricity cost.
What you'll learn: AC signal sampling with analogRead(), RMS calculation over multiple samples, ACS712 zero-offset calibration, power factor concepts, and energy (kWh) accumulation over time.
Estimated time: 2–3 hours. Difficulty: ⭐⭐⭐ Intermediate.
Components Needed
| Component | Specification | Qty | Notes |
|---|---|---|---|
| Arduino Uno R3 | 5V Logic | 1 | Core ADC platform |
| ZMPT101B Voltage Sensor | AC 250V, analog out | 1 | Mains voltage measurement |
| ACS712-20A Module | Hall current sensor | 1 | 20A range, 100mV/A sensitivity |
| 16x2 I2C LCD | PCF8574 backpack | 1 | Displays power readings |
| AC Extension Cord | For inline wiring | 1 | Cut and insert ACS712 inline |
Step-by-Step Tutorial
1
Wire Voltage Sensor
Connect ZMPT101B VCC to 5V, GND to GND, and OUT to Arduino A0. The module safely steps down 230V AC to a 0–5V AC signal centred at 2.5V.
2
Wire Current Sensor
Cut the live wire of your AC extension cord and pass it through the ACS712 terminal block. Connect ACS712 VCC to 5V, GND to GND, OUT to A1.
3
Calibrate Zero-Offset
With no load connected, read A1 values in Serial Monitor. Note the midpoint value (should be ~512 for 5V/10-bit). Subtract this in code as the zero-current offset.
4
Implement RMS Sampling
Sample A0 and A1 1000 times over one AC cycle (20ms @ 50Hz). Square each sample, average, then take the square root to get Vrms and Irms.
5
Display Power & Cost
Calculate
P = Vrms × Irms × powerFactor. Accumulate energy as E += P × Δt / 3600000 (in kWh). Display on LCD with a user-set cost per kWh.⚠️ SAFETY: The ZMPT101B and ACS712 are optically/magnetically isolated, but you are still working near mains voltage. Always insulate all bare wires with heat-shrink tubing and never touch the circuit while plugged in.
Code / Configuration
smart_energy_meter.ino
INO
// Smart Energy Meter - Volt X
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int voltPin = A0; // ZMPT101B output
const int currPin = A1; // ACS712 output
const int samples = 1000;
const float supplyV = 5.0;
const float adcRes = 1023.0;
// ACS712-20A: 100mV per A, midpoint = 512 (calibrate!)
const float currOffset = 512.0;
const float mVperAmp = 0.1; // 100mV/A for 20A model
const float costPerKwh = 0.12; // USD
float vrms = 0, irms = 0, power = 0;
double energy = 0; // kWh
unsigned long lastTime = 0;
void setup() {
Serial.begin(9600);
lcd.init(); lcd.backlight();
}
Reviews & Ratings
—0 reviews
Sign in to leave a review
Loading reviews...