IoT Energy Meter With Protections Using PZEM-004T Source Code
₹699.00 Original price was: ₹699.00.₹499.00Current price is: ₹499.00.
Description
This source code implements a complete, production-ready Smart IoT Energy Meter built around the PZEM004T v3 energy monitoring module. It is designed for real-world AC load monitoring, protection, and remote control through a modern web dashboard, while also providing clear local feedback on a 20×4 I2C LCD.
⚠️ Important Notice
It is a digital product, so no refund will be given after purchase. If you face any issue contact me within 3 days of purchase. Nothing will be entertained after this time period.
Components Required
- ESP8266 NodeMCU Board / ESP32 Dev Board
- PZEM-004T Version 3.0 or 4.0
- 20×4 I2C LCD Display (SDA, SCL Enabled)
- 5V/10A 2 Channel Relay Module
- 5V DC Adapter
- Push Button
- AC Socket (as load)
- 1.5sqmm Electrical Wires
Files You Will Get
Source Code Uploading Process
ESP266 Board Install
First open the Arduino IDE software and goto Files → Preferences → Settings → Find Additional Board Manager (at the bottom) → Paste this below url at the black section → Click OK
https://arduino.esp8266.com/stable/package_esp8266com_index.jsonAfter this, goto Tools → Board → Boards Manager → Search for ESP8266 → Install the first board (esp8266 by ESP8266 Community) you get and done.
Wifi & Password Change
Now see the coding section. Find line number 10 where you will find “YOUR WIFI SSID”. Just replace with your own WiFi Name with quatation.
Also find line number 11 and replace the “YOUR WIFI PASSWORD” with your own WiFi password.
Source Code Upload Process
Now after doing all goto Tools → Board → esp8266 → select NodeMCU 1.0 (ESP-12E Module)
Next again goto Tools → Port → select correct Port → click on Upload button and done.
ESP32 Board Install
First open the Arduino IDE software and goto Files → Preferences → Settings → Find Additional Board Manager (at the bottom) → Paste this below url at the black section → Click OK
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.jsonAfter this, goto Tools → Board → Boards Manager → Search for ESP32 → Install the second board (esp32 by Expressif Systems) you get and done.
Wifi & Password Change
Now see the coding section. Find line number 12 where you will find “YOUR WIFI SSID”. Just replace with your own WiFi Name with quatation.
Also find line number 13 and replace the “YOUR WIFI PASSWORD” with your own WiFi password.
Source Code Upload Process
Now after doing all goto Tools → Board → esp32 → select ESP32 Dev Module
Next again goto Tools → Port → select correct Port → click on Upload button and done.
🔹 Specifications
Real-Time Electrical Measurement
- Accurate Voltage (V), Current (A), Power (W), Energy (kWh) readings from PZEM004T
- Displays Power Factor (PF) and Frequency (Hz)
- Automatic handling of invalid or disconnected mains states
Smart Protection System
- Over-Voltage Protection
- Under-Voltage Protection
- Over-Current Protection
- Automatic relay cutoff with clear fault reason (e.g., Over Voltage, Disconnected)
Relay Control
- Supports Active-LOW relay
- Three operating modes:
- AUTO – Smart protection enabled
- MANUAL ON
- MANUAL OFF
- Relay state automatically restored after reboot
Non-Volatile Configuration
- Uses LittleFS to store:
- Voltage & current thresholds
- Relay operating mode
- Settings persist even after power loss or reset
🌐 Built-In Web Dashboard
- Responsive, mobile-friendly UI
- Live values update automatically (AJAX/JSON based)
- Animated AC mains ON/OFF indicator
- One-click relay control (ON / OFF / AUTO)
- Adjustable protection thresholds directly from browser
- Clean API endpoints for integration with apps or cloud services
🖥️ Local Display & Controls
- 20×4 I2C LCD shows:
- Page 1: Voltage, Current, Power, System Status
- Page 2: Energy, PF, Frequency, Mode & Thresholds
- Single button to switch display pages
- Clear startup messages for WiFi / AP mode and IP address
📡 WiFi & Network Behavior
- Connects automatically to configured WiFi network
- If WiFi fails, device starts its own Access Point (AP mode)
- Dashboard accessible via local IP – no cloud dependency
🧠 Software Architecture Highlights
- Clean modular structure (Protection, Web, LCD, Config)
- JSON-based API for easy extension
- Interrupt-based button handling with debounce
- Safe relay logic prevents energizing load during fault conditions
🔌 Typical Applications
- Home or industrial smart energy meters
- AC load protection & monitoring panels
- IoT-based power consumption logging
- Smart distribution boards
- DIY or commercial automation projects
📦 What You Get (Source Code)
- Fully commented ESP8266 & ESP32 source code
- Integrated HTML + CSS + JavaScript dashboard
- LittleFS configuration handling
- Ready to compile and upload with Arduino IDE
⚠️ Important Notes
- Designed for PZEM004T v3 and v4 (UART version)
- Use proper electrical isolation and safety precautions
- Relay must be rated for target AC load





Reviews
There are no reviews yet.