Zbotic Logo Zbotic Logo
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

  • Shop
  • About Us
  • Contact Us
  • Reseller
  • Blogs
020 69134444
1800 209 0998
[email protected]
Help Desk
Facebook Twitter Instagram Linkedin YouTube
Zbotic Logo Zbotic Logo
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

All departments
  • 3D Print Service
  • 3D Printer
  • Batteries & Chargers
  • Development Boards
  • Drone Parts
  • EBike parts
  • Sensor Modules
  • Electronic Components
  • Electronic Modules
  • IoT and Wireless
  • Mechanical Parts and Workbench Tools
  • Motors & Drivers & Pumps & Actuators
  • DIY and Robot Kits
  • Show more
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
Return to previous page
Home Home Automation & Smart Devices

Smart Plug Build: Energy Monitoring with ESP32 and Blynk

Smart Plug Build: Energy Monitoring with ESP32 and Blynk

March 11, 2026 /Posted byJayesh Jain / 0

Building a smart plug with energy monitoring using ESP32 and Blynk gives you a powerful tool to track, control, and optimise your appliance power consumption. Unlike commercial smart plugs that are limited to simple on/off control, a DIY ESP32 smart plug with PZEM-004T measures real-time voltage, current, wattage, and cumulative energy — giving you data that is directly usable for calculating your electricity bill and identifying energy hogs. This project costs Rs 800-1,200 to build versus Rs 1,500-3,000 for commercial energy-monitoring smart plugs.

Table of Contents

  • Components and BOM
  • Safety Guidelines for 230V Projects
  • Circuit Design
  • ESP32 Code with Blynk
  • Blynk Dashboard Setup
  • Alternative: MQTT to Home Assistant
  • Indian Electricity Bill Calculator
  • Frequently Asked Questions

Components and BOM

  • ESP32 DevKit V1 — Rs 200-350
  • PZEM-004T V3.0 energy monitoring module — Rs 400-600
  • 5V 1-channel relay module — Rs 50-80
  • HiLink HLK-PM03 3.3V or PM05 5V power module — Rs 150-250
  • Indian 5A socket and plug (for enclosure outlets) — Rs 80-120
  • ABS enclosure (suitable for mains wiring) — Rs 150-250
  • Terminal blocks and 10A wire — Rs 80-120

Total: Rs 1,110-1,770. Cheaper than most commercial energy monitoring smart plugs with far more data.

Recommended: ESP32 with OLED Display — Add this integrated OLED display to your smart plug design. Show real-time wattage, daily kWh, and cost on the plug itself — no phone needed for quick power readings when walking past the appliance.

Safety Guidelines for 230V Projects

  • Always work with power disconnected from mains
  • Use ABS or fireproof enclosure rated for mains use
  • PZEM module must be connected via its CT clamp only — never connect high-voltage terminals to ESP32
  • All mains connections must be properly insulated
  • Add a 5A fuse in series with the load circuit
  • Earthing: connect enclosure to earth if metal

Circuit Design

Power Section (230V Mains):
Input Live (L) -- [5A fuse] -- Relay COM
Relay NO -- PZEM CT wire -- Output Socket Live
Input Neutral -- Output Socket Neutral
Input Earth -- Output Socket Earth

PZEM-004T:
- Input clamps (L, N) connect to INPUT mains live and neutral
- Output terminal monitors the switched load
- CT clamp wraps around the OUTPUT live wire
- PZEM RX/TX connect to ESP32 Serial2

HiLink Power Module:
- L and N inputs from mains
- 5V output to relay VCC and ESP32 VIN
- GND output to common ground

ESP32 Connections:
GPIO26 -> Relay IN (control)
GPIO16 -> PZEM RX
GPIO17 -> PZEM TX
VIN <- 5V from HiLink
GND <- HiLink GND

ESP32 Code with Blynk

#define BLYNK_TEMPLATE_ID "TMPL_XXXXXX"
#define BLYNK_TEMPLATE_NAME "SmartPlug"
#define BLYNK_AUTH_TOKEN "YOUR_AUTH_TOKEN"

#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
#include <PZEM004Tv30.h>

const char* ssid = "YOUR_WIFI";
const char* pass = "YOUR_PASS";

#define RELAY_PIN 26
PZEM004Tv30 pzem(Serial2, 16, 17);

BlynkTimer timer;

void sendEnergyData() {
  float voltage = pzem.voltage();
  float current = pzem.current();
  float power = pzem.power();
  float energy = pzem.energy(); // kWh accumulated
  float frequency = pzem.frequency();
  float pf = pzem.pf();
  
  if (!isnan(voltage)) {
    Blynk.virtualWrite(V0, voltage);      // Volts
    Blynk.virtualWrite(V1, current);      // Amps
    Blynk.virtualWrite(V2, power);        // Watts
    Blynk.virtualWrite(V3, energy);       // kWh
    Blynk.virtualWrite(V4, frequency);    // Hz
    Blynk.virtualWrite(V5, pf);          // Power factor
    
    // Calculate bill contribution
    float ratePerUnit = 7.50; // Rs per kWh - adjust for your state
    float dailyCost = energy * ratePerUnit;
    Blynk.virtualWrite(V6, dailyCost);
  }
}

// Control relay from Blynk app
BLYNK_WRITE(V7) {
  int state = param.asInt();
  digitalWrite(RELAY_PIN, state == 1 ? HIGH : LOW);
}

void setup() {
  Serial.begin(115200);
  pinMode(RELAY_PIN, OUTPUT);
  digitalWrite(RELAY_PIN, LOW); // Start OFF
  
  Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
  timer.setInterval(5000L, sendEnergyData); // Every 5 seconds
}

void loop() {
  Blynk.run();
  timer.run();
}

Blynk Dashboard Setup

  1. Create a Blynk account at blynk.io
  2. Create a new template: “SmartPlug”
  3. Add datastreams for V0-V7
  4. Create a Web Dashboard with:
    • Gauge (V0): Voltage display (220-240V range)
    • Gauge (V1): Current (0-15A)
    • Gauge (V2): Power (0-2300W)
    • Chart (V3): Energy over time (kWh history)
    • Label (V6): Daily cost in Rs
    • Button (V7): ON/OFF relay control
  5. Create matching mobile dashboard in the Blynk app

Alternative: MQTT to Home Assistant

Replace Blynk with MQTT for local, cloud-free control:

#include <PubSubClient.h>

WiFiClient wifiClient;
PubSubClient mqtt(wifiClient);

void publishData() {
  mqtt.publish("smartplug/voltage", String(pzem.voltage()).c_str());
  mqtt.publish("smartplug/power", String(pzem.power()).c_str());
  mqtt.publish("smartplug/energy", String(pzem.energy()).c_str());
}

mqtt.subscribe("smartplug/relay/set");
// Receive ON/OFF from Home Assistant

Indian Electricity Bill Calculator

Use the energy data to calculate actual running costs for each appliance:

// Indian electricity tariff rates (2026 approximate)
// Adjust for your state and DISCOM:
float calculateMonthlyCost(float dailyKwh) {
  float monthlyKwh = dailyKwh * 30;
  float cost = 0;
  
  // Example: Maharashtra slab rates
  if (monthlyKwh <= 100) cost = monthlyKwh * 2.15;
  else if (monthlyKwh <= 300) cost = 100 * 2.15 + (monthlyKwh - 100) * 5.83;
  else cost = 100 * 2.15 + 200 * 5.83 + (monthlyKwh - 300) * 7.97;
  
  return cost;
}
Recommended: DC5V/8-80V ESP8266 WiFi Relay 2 Channel — Build a 2-outlet smart power strip by pairing this dual-relay module with a single PZEM-004T monitoring total consumption of both outlets — a cost-effective solution for monitoring a desk setup.
Recommended: 8 Channel SSR Module (OMRON) — Scale up to an 8-socket energy monitoring power strip using OMRON solid-state relays for silent, long-lasting switching — ideal for a home office or server rack smart plug setup.

Frequently Asked Questions

How accurate is PZEM-004T for Indian electricity billing?

The PZEM-004T has 0.5% voltage accuracy and 1% power accuracy — excellent for home monitoring. The accumulated kWh reading is calibrated but may drift slightly from your official DISCOM meter over time due to measurement methodology differences. Use it for relative consumption comparison rather than exact billing verification.

What is the maximum load this smart plug can handle?

Design it for 6A (1,380W at 230V) using the standard 5A relay and PZEM CT clamp. For heavier loads (geyser, AC, induction cooktop), use a 16A relay and the 100A CT version of PZEM-004T with external CT clamp, designing the enclosure and wiring for 16A continuously.

Can I reset the energy counter without losing accumulated data?

The PZEM-004T has a Modbus command to reset the energy counter (send register 0x42 with value 0). Implement a Blynk button (V8) mapped to this command for easy daily or weekly energy counter reset. Home Assistant can trigger this reset via an automation at midnight for daily energy tracking.

Shop Home Automation at Zbotic –

Tags: electricity monitoring, energy monitoring Blynk, home automation plug, PZEM-004T, smart plug DIY india, smart plug ESP32
Share Post
  • Facebook
  • Linkedin
  • Whatsapp
How to Win a Hackathon: Electr...
blog how to win a hackathon electronics build tips for students 599216
blog vga output from microcontroller resistor dac arduino code 599218
VGA Output from Microcontrolle...

Related posts

Svg%3E
Read more

MQTT for Home Automation: ESP32 + Mosquitto + Home Assistant

April 1, 2026 0
MQTT is the backbone protocol of professional home automation systems. If you are building a smart home with multiple ESP32... Continue reading
Svg%3E
Read more

Curtain and Blind Automation: Stepper Motor Controller

April 1, 2026 0
Curtain automation is one of the most satisfying smart home upgrades you can build. Imagine your curtains opening automatically at... Continue reading
Svg%3E
Read more

Smart Doorbell with Camera: ESP32-CAM Video Intercom

April 1, 2026 0
A smart doorbell with a camera lets you see who is at your door from your phone, even when you... Continue reading
Svg%3E
Read more

Blynk IoT Platform: Control Arduino and ESP32 from Mobile

April 1, 2026 0
The Blynk IoT platform is the fastest way to control your Arduino and ESP32 projects from your mobile phone. Instead... Continue reading
Svg%3E
Read more

PIR Sensor Automatic Light: Save Electricity with Motion Detection

April 1, 2026 0
PIR sensor automatic lights are the simplest and most effective way to save electricity in Indian homes. By automatically turning... Continue reading

Add comment Cancel reply

Your email address will not be published. Required fields are marked

Facebook Twitter Instagram Pinterest Linkedin Youtube

Get the latest deals and more.

Download on Google Play Download on the App Store

Call us: 020 69134444 / 1800 209 0998

Monday - Saturday 09:30 AM - 06:00 PM
For Technical Supports Email: [email protected]
For Sales / Enquiries Email: [email protected]

  • My Account

    • Cart

    • Wishlist

    • Checkout

    • My Orders

    • Track Order

    • My Account

  • Information

    • FAQs

    • Blogs

    • Career

    • About Us

    • Contact Us

    • Payment Options

  • Policies

    • Privacy Policy

    • Terms & Conditions

    • GST Input Tax Credit

    • Shipping Return Policy

    • E-Waste Collection Points

    • Our Sitemap

© Zbotic.in is registered trademark of Moxie Supply Pvt Ltd – All Rights Reserved
Login
Use Phone Number
Use Email Address
Not a member yet? Register Now
Reset Password
Use Phone Number
Use Email Address
Register
Already a member? Login Now