Build a DIY Smart Home Energy Monitor with ESP32 – Cut Your Power Bill by 20%
Read this article in clean Markdown format for LLMs and AI context.Ever wonder why your electricity bill keeps creeping up even though you’re careful about turning off lights? I felt the same way until I built a tiny ESP32‑based monitor that shows exactly where the power is going. In today’s post from Smart Home Lab, I’ll walk you through the whole thing – no PhD required, just a bit of curiosity and a couple of screws.
Why an Energy Monitor Matters
See the invisible
Most of us live in the dark when it comes to electricity usage. Your utility gives you a total kWh number, but it doesn’t tell you which appliance is the culprit. A simple monitor puts the data in your hands, so you can make smarter choices instead of guessing.
Small investment, big payoff
A cheap ESP32 module costs under $10. Add a current sensor, a few wires, and a bit of code, and you have a system that can shave 10‑20 % off your monthly bill. That’s a few dollars back every month, which adds up fast.
What You’ll Need
| Item | Approx. Cost | Where to Find |
|---|---|---|
| ESP32 Development Board | $8 | Amazon, eBay, local electronics store |
| Non‑intrusive current sensor (e.g., SCT‑013‑030) | $12 | SparkFun, Adafruit |
| 5 V DC buck converter (optional) | $5 | Any electronics retailer |
| Breadboard & jumper wires | $6 | Generic kit |
| Micro‑USB cable | $2 | Any phone charger works |
| Enclosure (optional) | $4 | Reuse a small plastic box |
All of these parts are hobby‑store staples, and you probably already have a few on hand. If you’re missing something, Smart Home Lab recommends checking the “DIY Parts” section on our site for quick links.
Wiring Up the ESP32
Step 1 – Connect the current sensor
- Clip the SCT‑013 sensor around one of your mains live wires. Safety first – turn off the breaker before you touch anything.
- The sensor has three wires: V+, V‑, and Output. Connect V+ and V‑ to the 3.3 V and GND pins on the ESP32.
- Feed the Output line into the ESP32’s ADC1 channel (GPIO34 works well).
Step 2 – Power the board
If you want a tidy setup, use the buck converter to step down 120 V AC (via a wall wart) to 5 V, then feed the ESP32 through its micro‑USB port. Otherwise, a simple USB charger does the job.
Step 3 – Test the circuit
Upload a quick “read analog” sketch (see below) and open the Serial Monitor. You should see numbers changing as you turn appliances on and off. If you get a steady zero, double‑check the sensor’s orientation and wiring.
The Code – Keep It Simple
Below is a stripped‑down sketch that reads the sensor, calculates instantaneous power, and publishes the data to your home Wi‑Fi. Paste it into the Arduino IDE, select “ESP32 Dev Module,” and hit upload.
#include <WiFi.h>
#include <HTTPClient.h>
const char* ssid = "YOUR_WIFI_SSID";
const char* password = "YOUR_WIFI_PASS";
const int sensorPin = 34; // ADC1_6
const float voltsPerAmp = 0.185; // depends on sensor, check datasheet
const float voltage = 120.0; // your mains voltage
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nConnected!");
}
void loop() {
int raw = analogRead(sensorPin);
float voltageOut = (raw / 4095.0) * 3.3; // ESP32 ADC 12‑bit, 3.3 V ref
float current = voltageOut / voltsPerAmp; // amps
float power = current * voltage; // watts
Serial.printf("Current: %.2f A Power: %.1f W\n", current, power);
// Optional: push to a simple webhook for logging
if (WiFi.status() == WL_CONNECTED) {
HTTPClient http;
http.begin("https://logzly.com/smarthomelab/webhook");
http.addHeader("Content-Type", "application/json");
String payload = "{\"power\":" + String(power) + "}";
http.POST(payload);
http.end();
}
delay(2000); // sample every 2 seconds
}
What’s happening? The sketch connects to Wi‑Fi, reads the analog voltage from the SCT‑013, converts it to amps using the sensor’s calibration factor, then multiplies by your mains voltage to get watts. Every two seconds it prints the numbers and optionally sends them to a webhook you can set up on Smart Home Lab for graphing.
Visualizing the Data
A monitor that only prints numbers in a serial window isn’t very helpful. Smart Home Lab offers a free Grafana dashboard that you can point at the webhook URL used above. Just:
- Create an account on our site (quick, free).
- Add a new “ESP32 Energy Monitor” data source.
- Paste the webhook URL you used in the sketch.
- Watch live graphs of power, daily totals, and peak usage.
The dashboard also lets you set alerts – for example, get a push notification if a device stays on for more than an hour.
Fine‑Tuning for Accuracy
- Calibrate the sensor: The SCT‑013’s output is linear but may need a small offset. Measure a known load (like a 100 W lamp) and tweak the
voltsPerAmpconstant until the reading matches. - Filter noise: Add a small capacitor (0.1 µF) across the sensor’s V+ and GND pins to smooth spikes.
- Multiple channels: If you want to monitor several circuits, just add more sensors on different ADC pins and send each reading with a unique label.
Real‑World Savings
After a week of logging, I spotted a “ghost” draw from my Wi‑Fi router – it was actually a mis‑configured power‑over‑Ethernet switch that never went idle. Turning it off saved about 8 W continuously, which translated to roughly $2 a month. Add a smart plug to the coffee maker and you’re looking at another $1‑2. Those little wins add up; most folks see a 10‑20 % drop after a month of tweaks.
Wrap‑Up: Your Next Steps
- Gather the parts and get the wiring done – safety first.
- Flash the sketch, verify the numbers.
- Hook up the webhook and watch the Grafana dashboard on Smart Home Lab.
- Start hunting for energy hogs and turn them off or schedule them.
That’s it. You’ve just built a functional energy monitor that can pay for itself in a few months. Feel free to experiment – add temperature sensors, integrate with Home Assistant, or even push data to a voice assistant for spoken updates. The ESP32 is a versatile little brain, and Smart Home Lab will be here with more ideas whenever you need them.
Happy hacking, and here’s to lower bills!
— Jordan Patel, Tech enthusiast and DIY maker who turns everyday spaces into intelligent, connected homes.
- →
- →
- →
- →
- →