This guide shows you how to build a wireless energy meter that measures voltage, current, power and energy (kWh) from a real mains load, shows the readings on an LCD, uploads them to the cloud over Wi-Fi, and calculates the electricity bill. It is a student and final year project — a working prototype you can demonstrate with a real load like a light bulb.
Safety warning — read first: this project connects to 220V AC mains electricity, which can kill. Build it only with adult supervision, never touch the PZEM module's mains terminals while power is connected, and enclose the finished meter in an insulated box. Test it first with a small load (a 60W bulb) and never work on live mains wiring alone.
Also important: this is a student prototype, not a certified billing meter. Real electricity billing uses a certified meter from the power company — this project shows how metering and billing work, it does not replace the real meter.

This project uses the ESP32 only. The PZEM-004T talks over a second hardware serial port (Serial2 on GPIO 16 and 17), and the billing upload needs Wi-Fi. The Arduino Uno has no second hardware serial port and no Wi-Fi, so it cannot run this code. The earlier version of this post listed "ESP32 / Arduino Uno" — that was wrong, and it is corrected here.
| Component | Specification | Price / link |
|---|---|---|
| ESP32 Dev Module | 30-pin Wi-Fi + Bluetooth board | ESP32 30-Pin Wi-Fi Bluetooth Development Board — Rs 1,100 |
| Energy meter module | PZEM-004T (with built-in CT clamp) | — |
| Display | 16x2 LCD with I2C | — |
| Power supply | 5V SMPS / 5V USB adapter | — |
| Load for testing | 60W bulb with holder | — |
| Breadboard + jumper wires | — | — |
The PZEM-004T is a module with its own current transformer (CT) clamp — you do not need a separate CT coil. The earlier parts list had a separate CT coil, which was redundant. The PZEM-004T, LCD and 5V supply do not have individual listings in the QKZEE shop — they are available at the Hall Road shop on request.
| Connection | Pins | Notes |
|---|---|---|
| PZEM VCC | ESP32 5V (VIN) | 5V supply |
| PZEM GND | ESP32 GND | — |
| PZEM TX | ESP32 GPIO 16 (RX2) | Serial2 receive |
| PZEM RX | ESP32 GPIO 17 (TX2) | Serial2 transmit |
| PZEM L terminal | Mains live (220V) | Mains — adult supervision only |
| PZEM N terminal | Mains neutral (220V) | Mains — adult supervision only |
| CT clamp | Around the LIVE wire only | Clamp it around one wire, never both — around both wires it reads zero |
| LCD SDA | GPIO 21 | I2C data |
| LCD SCL | GPIO 22 | I2C clock |
| LCD VCC / GND | 5V / GND | Most I2C LCD backpacks run on 5V |
The PZEM module measures voltage from its L and N terminals and current from the clamp. The clamp must go around the live wire only — if it goes around both the live and neutral wires, the currents cancel out and it reads zero.
The PZEM-004T measures the mains voltage directly and the load current through its clamp. It calculates power (voltage x current) and adds up energy over time in kWh. The ESP32 reads these values over Serial2, shows them on the LCD, and every 20 seconds uploads them to ThingSpeak. The bill is simply energy used (kWh) x your tariff rate (Rs per unit) — the tariff is one number in the code that you set to your area's rate.
Install these libraries first from the Arduino IDE Library Manager (Sketch - Include Library - Manage Libraries):
Then upload this sketch. Replace the Wi-Fi name, password and ThingSpeak Write API Key with your own (see the ThingSpeak section below). Set TARIFF_PER_UNIT to your area's electricity rate in Rs per kWh.
/*
Wireless Energy Meter with Mobile Billing
Reads voltage, current, power and energy from PZEM-004T,
shows them on a 16x2 LCD, uploads to ThingSpeak,
and calculates the bill from the tariff rate.
Board: ESP32 Dev Module. PZEM-004T on Serial2 (RX2 = GPIO 16, TX2 = GPIO 17).
LCD on I2C (SDA GPIO 21, SCL GPIO 22).
*/
#include <WiFi.h>
#include <HTTPClient.h>
#include <PZEM004Tv30.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define PZEM_RX_PIN 16
#define PZEM_TX_PIN 17
const char* ssid = "YOUR_WIFI_NAME";
const char* password = "YOUR_WIFI_PASSWORD";
const char* thingSpeakApiKey = "YOUR_THINGSPEAK_WRITE_API_KEY";
const float TARIFF_PER_UNIT = 35.0; // Rs per kWh - change to your area's rate
PZEM004Tv30 pzem(Serial2, PZEM_RX_PIN, PZEM_TX_PIN);
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
Serial.begin(115200);
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Energy Meter");
lcd.setCursor(0, 1);
lcd.print("Starting...");
WiFi.begin(ssid, password);
Serial.print("Connecting to WiFi");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nWiFi connected");
}
void loop() {
float voltage = pzem.voltage();
float current = pzem.current();
float power = pzem.power();
float energy = pzem.energy();
if (isnan(voltage)) {
Serial.println("PZEM not responding - check wiring!");
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("PZEM no reply");
lcd.setCursor(0, 1);
lcd.print("Check wiring");
delay(2000);
return;
}
float bill = energy * TARIFF_PER_UNIT;
Serial.print("Voltage: ");
Serial.print(voltage);
Serial.print(" V | Current: ");
Serial.print(current);
Serial.print(" A | Power: ");
Serial.print(power);
Serial.print(" W | Energy: ");
Serial.print(energy);
Serial.print(" kWh | Bill: Rs ");
Serial.println(bill);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(voltage, 0);
lcd.print("V ");
lcd.print(current, 2);
lcd.print("A ");
lcd.print(power, 0);
lcd.print("W");
lcd.setCursor(0, 1);
lcd.print(energy, 3);
lcd.print("kWh Rs");
lcd.print(bill, 0);
// ThingSpeak accepts an update at most every 15 seconds
static unsigned long lastUpload = 0;
if (millis() - lastUpload > 20000 && WiFi.status() == WL_CONNECTED) {
HTTPClient http;
String url = "http://api.thingspeak.com/update?api_key=" + String(thingSpeakApiKey)
+ "&field1=" + String(voltage)
+ "&field2=" + String(current)
+ "&field3=" + String(power)
+ "&field4=" + String(energy);
http.begin(url);
Serial.print("ThingSpeak response: ");
Serial.println(http.GET());
http.end();
lastUpload = millis();
}
delay(2000);
}YOUR_THINGSPEAK_WRITE_API_KEY, along with your Wi-Fi name and password.Firebase and Blynk are also possible for this project, but the sketch above uses ThingSpeak because it is the simplest free option for a student demo: no app to build, just a web dashboard.
This is a learning prototype, not a certified billing meter. Its readings are good enough for a demo, but real billing always uses a certified meter.
The ESP32 board is available at QKZEE Technologies, Shop 20, 1st Floor, Al-Khalil Center, Hall Road, Lahore, and online at qkzeetech.com with delivery all over Pakistan — see the link in the components table above. The PZEM-004T module, LCD and 5V supply are available at the Hall Road shop on request.
If the PZEM does not respond, or your ThingSpeak charts stay empty, message us — tell us what the Serial Monitor shows (copy the exact lines) and which step you are on, and we will help you find the fault. For anything involving mains wiring, ask an adult or an electrician — do not guess.
Chat on WhatsApp Watch on YouTube
Can I use an Arduino Uno for this project?
No. The PZEM-004T needs a second hardware serial port and the billing upload needs Wi-Fi. The Uno has neither. Use the ESP32 as shown in this guide.
Is the PZEM-004T an IC or a module?
It is a module — a complete board with its own current transformer clamp, voltage sensing and serial interface. You do not need a separate CT coil.
Why does my current read zero with the load on?
The CT clamp is almost certainly around both the live and neutral wires. It must go around the live wire only — around both wires the currents cancel out and it reads zero.
Why does the energy reading reset to zero?
The PZEM-004T stores its energy counter in volatile memory, so it forgets the total when it loses power. Note the reading down before switching off.
How is the bill calculated?
Bill = energy used (kWh) x tariff rate (Rs per unit). The tariff is the TARIFF_PER_UNIT number in the code — set it to your area's actual rate. The bill on the LCD updates as energy grows.
Is this meter safe to use on real mains?
Only with adult supervision and an insulated enclosure, and only after testing with a small load like a 60W bulb. Never touch the PZEM's mains terminals while power is connected, and never work on live mains wiring alone.
Building a wireless energy meter with an ESP32 and a PZEM-004T is a strong final year project: it combines mains sensing, serial communication, Wi-Fi, and cloud dashboards in one working system. Follow the wiring above, test with a small load first, and you will have live voltage, current, power, energy and billing figures on ThingSpeak to show your teachers and judges.