Home Energy Monitor: Current Sensor and Dashboard Build
A home energy monitor gives you real-time insight into your electricity consumption — how much your AC draws at different temperatures, which appliance is causing your bill to spike, and whether your solar panels are actually saving what the installer promised. With an SCT013 current sensor, an ESP32, and a free Grafana or Home Assistant dashboard, you can build a whole-house energy monitor for under Rs. 1,500 that rivals commercial units costing Rs. 15,000-25,000.
This guide covers current transformer (CT) sensors for non-invasive monitoring (no mains wiring required), voltage sensing for accurate power factor measurement, and building a real-time dashboard that shows kilowatt-hours, cost in rupees, and per-appliance breakdowns.
CT Sensors and Their Types
Current transformer (CT) sensors clamp around a single wire and measure the magnetic field produced by current flow. They require no interruption to your mains wiring — just clip the CT around the live wire:
- SCT013-000 (100A): Most popular for whole-house monitoring. Outputs 0-50 mA proportional to 0-100A. Use with burden resistor.
- SCT013-030 (30A): Better accuracy for individual appliance monitoring (AC units, geysers). Outputs 1V max — no burden resistor needed.
- YHDC SCT-013: Same as SCT013, OEM brand used in most Indian kits. Available from Robu.in and Quartzcomponents.
- PZEM-004T: Complete all-in-one module with internal current transformer, voltage sensing, power factor measurement, and UART output. The most beginner-friendly option.
Hardware Setup
For the SCT013-000 (100A current output type) with an ESP32:
Components:
- SCT013-000 or YHDC CT sensor
- ESP32 (12-bit ADC for better resolution than ESP8266’s 10-bit)
- 33-ohm burden resistor (converts CT current to measurable voltage)
- Two 10k resistors (voltage divider to bias ADC midpoint to 1.65V)
- 10 microfarad capacitor (filter)
- 3.5mm stereo jack socket (CT sensor has 3.5mm plug)
Circuit: The burden resistor converts the CT’s current output to a voltage. The voltage divider biases the ADC input to the midpoint of the 3.3V supply so the AC waveform swings above and below the bias point. The capacitor filters out high-frequency noise.
CT Sensor 3.5mm TIP --+-- 33 ohm --+
| |
CT Sensor SLEEVE -----+ ADC1 |
|
3.3V --10k-- +--10k-- GND |
| |
+---------------------+
| ADC pin = ESP32 GPIO34
Recommended Product
ESP32 LoRa with OLED Display
The ESP32’s 12-bit ADC (4096 levels vs ESP8266’s 1024) gives 4x better current measurement resolution. The built-in OLED displays real-time watts and today’s kWh consumption without needing a phone or computer.
EmonLib: Energy Monitoring Library
EmonLib by OpenEnergyMonitor is the standard library for CT sensor energy monitoring. It handles RMS calculation, calibration, and apparent power computation:
#include <EmonLib.h>
EnergyMonitor emon1;
void setup() {
Serial.begin(115200);
// Pin 34, calibration factor
// SCT013-000: calibration = (100A / 0.05A) / 33 ohm = 60.6
emon1.current(34, 60.6);
}
void loop() {
double Irms = emon1.calcIrms(1480); // 1480 samples
double power = Irms * 230; // Apparent power in VA
double realPower = power * 0.9; // Assume 0.9 power factor
Serial.print("Current: "); Serial.print(Irms); Serial.println(" A");
Serial.print("Power: "); Serial.print(power); Serial.println(" VA");
delay(5000);
}
To calibrate the 60.6 factor: connect a known load (an incandescent bulb or electric iron is ideal — purely resistive). Adjust the calibration value until your reading matches a commercial clamp meter measurement. For India’s 230V 50Hz supply, typically 56-65 works for SCT013-000 with a 33-ohm burden resistor.
PZEM-004T: Complete Energy Module
The PZEM-004T module is the easiest approach — it measures voltage, current, power, energy (kWh), frequency, and power factor with high accuracy (+/- 0.5%):
#include <PZEM004Tv30.h>
#include <HardwareSerial.h>
// PZEM TX -> ESP32 GPIO16, PZEM RX -> GPIO17
HardwareSerial pzemSerial(2);
PZEM004Tv30 pzem(pzemSerial, 16, 17);
void loop() {
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(); // Power factor 0-1
Serial.printf("%.1fV %.2fA %.1fW %.3fkWh PF:%.2fn",
voltage, current, power, energy, pf);
delay(1000);
}
The PZEM-004T is designed for Indian 230V 50Hz supply. Its energy register resets with a software command — useful for daily kWh tracking and electricity bill calculation.
Home Assistant Integration
Publish PZEM or EmonLib readings to Home Assistant via MQTT:
// MQTT publishing example
char payload[200];
snprintf(payload, sizeof(payload),
"{"voltage":%.1f,"current":%.2f,"
""power":%.1f,"energy":%.3f,"pf":%.2f}",
voltage, current, power, energy, pf);
mqttClient.publish("home/energy/main", payload);
In Home Assistant configuration.yaml:
mqtt:
sensor:
- name: "Main Power"
state_topic: "home/energy/main"
value_template: "{{ value_json.power }}"
unit_of_measurement: "W"
device_class: power
- name: "Daily Energy"
state_topic: "home/energy/main"
value_template: "{{ value_json.energy }}"
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
The state_class: total_increasing setting enables the Energy Dashboard in Home Assistant (Settings → Energy) which automatically calculates daily, monthly, and yearly consumption totals.
Recommended Product
ESP8266 WiFi Relay Module
Combine your energy monitor with a relay module for automatic load control — cut off high-consumption appliances when total home load exceeds a threshold. Useful during peak tariff hours or when running on solar/inverter to prevent overload.
Grafana Dashboard Build
For beautiful historical charts, send energy data to InfluxDB and visualise with Grafana:
- Install InfluxDB on your Raspberry Pi:
sudo apt install influxdb influxdb-client - Install Grafana: download from grafana.com for ARM
- Publish ESP32 readings to InfluxDB using the InfluxDB Arduino library
- In Grafana: add InfluxDB data source, create panels for Power (Watts), Energy (kWh), and Voltage
Key Grafana panels for an Indian home energy dashboard:
- Real-time power gauge: shows current watts with colour zones (green=low, yellow=medium, red=high)
- Daily bar chart: kWh consumed per day for the past 30 days
- Monthly trend line: compare this month vs same month last year
- Cost estimate: calculated field using your state’s DISCOM slab rates
Indian Electricity Tariff Calculator
Different states have different DISCOM slab rates. Here is an ESPHome lambda to calculate approximate monthly cost for Maharashtra (MSEDCL residential slabs):
sensor:
- platform: template
name: "Estimated Monthly Bill"
unit_of_measurement: "Rs"
lambda: |-
// MSEDCL 2025 residential slabs (approx)
float kwh = id(monthly_energy).state;
float cost = 0;
if (kwh <= 100) {
cost = kwh * 3.26; // Slab 1: 0-100 units
} else if (kwh <= 300) {
cost = 100 * 3.26 + (kwh - 100) * 5.66; // Slab 2
} else {
cost = 100 * 3.26 + 200 * 5.66 + (kwh - 300) * 8.35; // Slab 3+
}
return cost;
update_interval: 3600s
Adjust the rates for your state: Delhi (BSES/TPDDL), Karnataka (BESCOM), Tamil Nadu (TANGEDCO), Gujarat (DGVCL), Rajasthan (JVVNL) all have different slab structures. Check your latest electricity bill for the exact per-unit rates.
Recommended Product
Waveshare 30-Channel Ethernet Relay
For commercial or large residential buildings, the 30-channel Ethernet relay with Modbus TCP allows individual circuit monitoring and control from a single module. Connect one PZEM-004T per circuit group for sub-meter visibility across the entire property.
Frequently Asked Questions
How accurate is the SCT013 vs a commercial energy meter?
With proper calibration, the SCT013 + EmonLib achieves 2-3% accuracy for resistive loads. For reactive loads (motors, inverters, LED drivers), accuracy depends on power factor compensation. The PZEM-004T achieves 0.5% accuracy and measures power factor natively — recommended for billing-grade measurements.
Can I monitor individual circuits (AC, geyser, kitchen) separately?
Yes — use one CT sensor per circuit. Multiple CT sensors can connect to the same ESP32 (different ADC pins). For a typical Indian home, monitor the AC circuit, geyser circuit, and main panel for three-circuit sub-metering with one ESP32 and three CT sensors.
Will this work in a flat where the distribution board is in the stairwell?
Yes, if you can access the DB to clip the CT sensor. The SCT013 is compact (fits around 6mm cable) and the ESP32 can be mounted near the DB with a small USB power supply. Data goes over WiFi, so no wiring from the DB to the flat.
How do I reset the PZEM-004T energy counter daily?
Use pzem.resetEnergy() in your ESP32 code, triggered by a daily schedule automation in Home Assistant or a time-based trigger in the ESP32 loop (check for midnight IST). This gives you daily kWh totals for easy bill estimation.
Can I monitor three-phase supply (used in some Indian villas and shops)?
Yes — use three PZEM-004T modules, one per phase. Address each module uniquely via Modbus and sum the readings for total three-phase power. This configuration monitors R, Y, B phase independently, which is useful for load balancing.
Monitor and Cut Your Electricity Bill
Real-time energy monitoring with current sensors and ESP32. Know exactly what is consuming power and when. Build your dashboard for under Rs. 1,500.
Add comment