Fall ResetAmazon USFall reset deals: check better picks before checkoutAmazon US: today's deals, useful picks and quick comparisons.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowFall ResetAmazon USWork and home upgrades are worth comparing todayAmazon US: today's deals, useful picks and quick comparisons.See Picks×
Skip to content
Blog

Smart Energy Bill Optimizer & Real-Time Power Monitor: ESP32 Project Guide

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

In brief: this is an ESP32-based electricity-monitoring prototype built around a PZEM-004T v3.0 module. It can report voltage, current, instantaneous power, accumulated energy, an estimated bill, MQTT telemetry and a basic over-current relay response. It is not a certified electrical-protection device, a utility-grade meter or a proven automatic bill-saving system.

The word “optimizer” needs qualification. The published design mainly provides visibility and estimation. It can support genuine optimization only after adding tariff-aware scheduling, load control and validation against the property’s actual electricity plan.

What the project actually does

The project measures electricity use and sends readings to an MQTT broker. Its demonstrated capabilities are:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Capability Status
Voltage monitoring Demonstrated
Current monitoring Demonstrated
Instantaneous power in watts Demonstrated
Accumulated energy in kWh Demonstrated
Fixed-rate bill estimate Demonstrated
MQTT reporting Demonstrated
Over-current alert and relay response Prototype/demo feature
Time-of-use scheduling Not demonstrated
Automatic appliance optimization Not demonstrated
Verified electricity savings No evidence supplied

That distinction matters on a construction or renovation project. A monitor can show where energy is being used, but it does not automatically reduce consumption. It should therefore be treated as a learning platform or monitoring prototype unless it is redesigned, tested and installed to an appropriate professional standard.

#1 Best Overall
Watt Meter Power Meter Plug Home Electricity Usage Monitor 7 Modes Display
  • Various Monitoring Parameters: The power meter plug can monitor the power (W), energy (kWh), volts, amps, hertz, power factor, cost, minimum and maximum power (W), cumulative days and time of your appliances. By switching 7 display modes, you can easily know the various parameters while the appliance is working. The home energy monitor can also calculate and display how much power your appliance uses and how much electricity bill it cost in cumulative time
  • Upgraded LCD Display: With large screen size 2.36 inch x 1.85 inch, clearer monitor backlit, our electrical usage monitor can display the data clearer and more visible no matter day or night. 180°full wide viewing angles is great for reading and recording the data in any angles. No need to stand on the front of the display and bend over to read the numbers
  • Adjustable Backlight Time: Our upgraded watt meter has 5 options of backlight time. The default backlight time duration is 10 minutes(bL-0). If you want to change the backlight time, you can press and hold "UP" and "DOWN" button at the same time to enter backlight time setting, then press "UP" and "DOWN" to select the backlight time (bL-0 =10 minutes, bL-1=1 hour, bL-2=4 hours, bL-3=8 hours, bL-4=always on), finally press the "COST" to save the backlight time settings
  • Overload protection: When the power of the appliance exceeds the overload power, the LCD will display “OVERLOAD” to warn the user. All the buttons will quit working and can only be workable when you lower or remove the load power. The default overload power is 3680W and is adjustable from 0 to 3680W. In general, you need to set the overload power to 1800W before using. Just press the "function" button for more than 3 seconds to enter the setting
  • Data Memory Function: The wattage meter will record your power consumption data when you remove it from socket, or remove appliances from the electricity monitor. You can directly see the last data when you use it next time. This function can also automatically save the data when there is a sudden power failure

The original implementation is documented on Hackster.io.

How the system works

AC load
  ↓
PZEM-004T v3.0 and CT sensor
  ↓ UART
ESP32
  ├── bill calculation
  ├── overload logic
  ├── Wi-Fi connection
  ↓
MQTT broker
  ↓
Dashboard, mobile app or home-automation system
  1. The PZEM module measures voltage, current, power and accumulated energy.
  2. The ESP32 reads those values over a hardware serial connection.
  3. The firmware calculates an estimated cost from accumulated kWh and a configured rate.
  4. Measurements and alerts are published through MQTT.
  5. A dashboard or automation platform can display the results.
  6. If current exceeds the configured threshold, the optional relay can disconnect a load.

The sample loop waits approximately 3,000 milliseconds between readings. That makes the project near-real-time telemetry rather than utility-grade instantaneous billing data. Sensor response time, Wi-Fi, MQTT latency and dashboard refresh settings also affect what the user sees.

Hardware architecture

Component Purpose
ESP32 Reads the monitor, calculates cost, connects to Wi-Fi and publishes MQTT messages.
PZEM-004T v3.0 Measures voltage, current, power and accumulated energy.
CT coil Measures current through the AC phase conductor.
5 V supply Powers the ESP32 and relay module as specified by the project.
Relay module Optional load-disconnect mechanism.
MQTT broker Receives readings and alerts for dashboards or other clients.

The project specifies ESP32 GPIO17 and GPIO16 for the PZEM serial connection and GPIO4 for the relay. Its code uses a 115200 baud rate. The CT is intended for the AC phase conductor only; its position, orientation and installation must follow the sensor manufacturer’s instructions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Important mains-safety warning

Do not open an energized distribution board or connect mains wiring as a beginner exercise. The project involves potentially lethal AC voltage, including systems around 220 V AC. Electrical requirements vary by country, supply voltage, phase arrangement, building type and local code. Panel work, fixed wiring, isolation, enclosure selection and commissioning should be reviewed and carried out by a suitably qualified electrician.

The ESP32 and MQTT portion is low-voltage electronics, but the CT installation, PZEM voltage connections and relay-controlled circuit may involve hazardous mains conductors. Keep low-voltage and mains wiring physically separated, use suitable insulation and enclosures, provide strain relief and isolation, and do not rely on a hobby relay board as the building’s protective device.

Rank #2
Upgraded Watt Meter Power Meter Plug Home Energy Monitor 8 Display Modes
  • Multi-function power monitor: Our electric usage monitor can monitor the power (W), electricity(kWh), voltage(V), frequency(Hz), current(A), power factor(PF), unit price($/kWh), total cost($) of your appliances. By switching 8 display modes, you can easily know the various parameters while the appliance is working. The “electricity” mode can calculate and display how much power your appliance uses. And the “total cost” mode will show how much electricity bill it cost in cumulative time
  • Overload protection: When the loading power of the appliance is over the default overload threshold 1800W, the whole display with backlight and the word “OVERLOAD” will keep flashing to warn the users. Please turn off the appliance for safety concern
  • Premium Material: The whole body of our energy meter is made of high-quality ABS material. It makes our home electricity usage monitor more long lasting, fireproof and anti-drop. The standard US socket and plug is suitable for all US standard appliances
  • Backlight Display: With white backlight and black words, the LCD display of our home power monitor can display the data clearer and help you to read the data easier no matter day or night. The backlight will only lights up when the device is connected to AC power. If no button is pressed, the backlight turns off automatically after 10 minutes. You can also press the "UP" button to turn off the backlight manually, and press any button to turn on backlight again
  • Easy to reset: No reset tool needed, our appliance power usage meter is easy to reset. You can press the “M” button for 5 seconds directly to reset the device. After reset, all cumulative data (electricity quantity, cost) will be cleared, and all settings will be restored to factory settings

Bill-estimation mathematics

The sample calculation is:

estimated bill = accumulated energy in kWh × electricity rate

Its example uses 150 kWh at ₹6 per unit:

150 kWh × ₹6/kWh = ₹900

The code expresses the same assumption as:

float electricityRate = 6.0;

₹6 per kWh is an illustrative fixed rate, not a universal electricity price. A real bill may also include:

  • tiered or block pricing;
  • time-of-use rates;
  • fixed customer charges;
  • demand charges;
  • taxes and other fees;
  • delivery or transmission charges;
  • solar export credits;
  • separate import and export rates; and
  • billing-period boundaries and meter-read dates.

For a useful estimate, the firmware should store the billing-cycle start and end times, apply a rate schedule, preserve energy data through resets and handle import, export, battery charging and battery discharge separately. A single floating-point rate is suitable for a demonstration, not for reproducing every utility bill.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

MQTT topics and security

The example publishes:

power/voltage
power/current
power/watt
power/energy
power/bill
power/alert
power/status

It also uses the public demonstration broker broker.hivemq.com on port 1883. That configuration should not be used for a permanent home, construction site or commercial installation. Public topics can expose readings, collide with other devices and create serious risks if relay commands are later added.

For a real deployment, use a private broker with:

  • username and password authentication;
  • TLS encryption;
  • a unique, non-predictable device namespace;
  • topic permissions separating read-only telemetry from control commands;
  • no publicly accessible relay-control topic;
  • retained status messages only where their meaning is well defined; and
  • firmware and broker update procedures.

For example, instead of generic topics, use a structure such as site-17/building-a/meter-01/telemetry/current, while keeping control topics separately authenticated.

Overload behavior is not electrical protection

The example sets:

float overloadCurrent = 10.0;

If measured current exceeds 10 A, the relay is switched and an overload alert is published. This is a prototype load-disconnect action. It is not a replacement for a correctly rated circuit breaker, fuse, safety-certified disconnect, suitable contactor, proper earthing or compliant installation.

Rank #3
Emporia Vue 3 Home Energy Monitor - Smart Home Automation Module and Real Time Electricity Usage Monitor, Power Consumption Meter, Solar and Net Metering for UL Certified Safe Energy Monitoring
  • SAFETY YOU CAN TRUST WITH UL CERTIFICATION: With Emporia Energy, your home energy monitoring is safe, reliable, and certified. The Emporia Vue is UL Listed, meaning it has met rigorous safety standards for electrical products in the U.S. and Canada. This certification ensures that every component has been thoroughly tested to prevent hazards, such as overheating, short-circuiting, or fire, offering you peace of mind as you manage your home’s energy consumption.
  • INSTALLS IN CIRCUIT PANEL of most homes with clamp-on sensors. Supports Single phase, Single-split phase, and 2-wire systems. 3-wire systems; 3-phase, 4-wire Wye systems with earthed (TN or TT) neutral (no-Delta) are supported with an additional 200A sensor (sold separately).
  • 24/7 ENERGY MANAGEMENT AND MONITORING: Automate, manage and control your home's real power anywhere, anytime to prevent costly repairs, conserve energy, and save costs. Monitor solar / net metering. PROTECTED BY A 1-YEAR WARRANTY.
  • LOWER YOUR ELECTRIC BILL: Configure settings in the Emporia Energy App to automate energy management for time of use, peak demand, excess solar, and rewards programs. You can even see live reporting and invaluable savings opportunities instantly. Gauge real-time spending and get actionable notifications and automated energy management to help you reduce costs.
  • REAL-TIME ENERGY DATA: REQUIRES 2.4 GHz WIFI WITH AN INTERNET CONNECTION to monitor energy use with iPhone / Android / Web app. Vue sensors collect energy data and are accurate from ±2%. The Vue is UL and CE Listed for your safety. 1 second data is only available in the app (when actively open) and retained 3 hours. Minute and hour data are retained in the cloud. 1 minute data is retained 7 days, 1 hour data is retained indefinitely. Export cloud data whenever you want in the app.

A fixed 10 A threshold may be unsuitable for the circuit, appliance, local electrical standard or starting characteristics of motors and compressors. Relay ratings can also be misleading: an advertised current rating may not apply to inductive, motor, compressor, heater or continuous loads.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Automatic reconnection deserves particular caution. Re-energizing a load after current falls can repeatedly cycle a damaged appliance or recreate a fault. A safer production design would normally consider a latched fault, manual reset, cooldown period, fault logging and a defined fail-safe state.

Firmware behavior and limitations

The project uses the Arduino IDE, the PubSubClient MQTT library and the PZEM004Tv30 library. The relevant flow is:

  1. Initialize the PZEM serial interface.
  2. Connect the ESP32 to Wi-Fi.
  3. Connect to the MQTT broker.
  4. Read voltage, current, power and energy.
  5. Calculate the estimated bill.
  6. Publish readings and status.
  7. Apply the over-current relay logic.
  8. Wait approximately three seconds and repeat.

The sample returns without publishing when voltage or current is NaN. That is a useful basic guard, but it does not provide complete fault handling. The published example does not show robust handling for Wi-Fi loss, MQTT authentication, reconnection backoff, sensor timeouts, duplicate client IDs, relay failure, calibration, power outages, tariff changes or energy-counter resets.

A more dependable version should use non-blocking reconnect logic, watchdog protection, local buffering, persistent billing data, explicit sensor fault states and a defined relay behavior when the network is unavailable. Remote control should fail safely rather than depending on a continuously available cloud connection.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
2 Pack Upgraded Watt Meter Power Meter Plug 7 Modes Display
  • Various Monitoring Parameters: The power meter plug can monitor the power (W), energy (kWh), volts, amps, hertz, power factor, cost, minimum and maximum power (W), cumulative days and time of your appliances. By switching 7 display modes, you can easily know the various parameters while the appliance is working. The home energy monitor can also calculate and display how much power your appliance uses and how much electricity bill it cost in cumulative time
  • Upgraded LCD display: With large screen size 2.36 inch x 1.85 inch, clearer monitor backlit, our electrical usage monitor can display the data clearer and more visible no matter day or night. 180°full wide viewing angles is great for reading and recording the data in any angles. No need to stand on the front of the display and bend over to read the numbers
  • Adjustable Backlight Time: Our upgraded watt meter has 5 options of backlight time. The default backlight time duration is 10 minutes(bL-0). If you want to change the backlight time, you can press and hold "UP" and "DOWN" button at the same time to enter backlight time setting, then press "UP" and "DOWN" to select the backlight time (bL-0 =10 minutes, bL-1=1 hour, bL-2=4 hours, bL-3=8 hours, bL-4=always on), finally press the "COST" to save the backlight time settings
  • Overload protection: When the power of the appliance exceeds the overload power, the LCD will display “OVERLOAD” to warn the user. All the buttons will quit working and can only be workable when you lower or remove the load power. The default overload power is 3680W and is adjustable from 0 to 3680W. In general, you need to set the overload power to 1800W before using. Just press the "function" button for more than 3 seconds to enter the setting
  • Data Memory Function: The wattage meter will record your power consumption data when you remove it from socket, or remove appliances from the electricity monitor. You can directly see the last data when you use it next time. This function can also automatically save the data when there is a sudden power failure

Calibration and validation

The published project does not supply an independent accuracy comparison against a calibrated meter, utility meter or known reference load. Do not describe the readings as accurate until the completed installation has been checked.

  1. Begin with a known resistive load and safe, supervised wiring.
  2. Compare displayed watts with a trusted reference meter.
  3. Run the load for a fixed, recorded period.
  4. Compare accumulated kWh with the reference.
  5. Repeat at low and high loads.
  6. Check CT orientation, closure and conductor placement.
  7. Test Wi-Fi loss and power cycling.
  8. Test relay logic without connecting a hazardous or valuable load.
  9. Record error, environmental conditions and uncertainty.

If energy rises while no load is operating, check CT placement, wiring, sensor configuration and whether the monitored conductor is carrying another circuit. If current remains zero, check that the CT surrounds only the intended phase conductor and is fully closed.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Turning monitoring into genuine optimization

Monitoring becomes optimization only when the system uses the information to choose or recommend a lower-cost operating strategy. Possible extensions include:

  • time-of-use rate schedules;
  • peak-demand alerts;
  • EV charging control;
  • smart-plug scheduling;
  • solar-surplus control;
  • battery charge and discharge scheduling;
  • appliance runtime limits;
  • historical baseline comparisons; and
  • human-readable recommendations.

Solar installations require particular care. A consumption-only monitor may not show the actual cost of grid imports when solar generation, export credits or batteries are involved. A complete design needs separate import and export flows and the applicable tariff rules.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Nor does this project identify individual appliances automatically. It measures aggregate or circuit-level quantities. Appliance-level disaggregation requires additional sensors, algorithms or smart plugs.

Best Value
Sale
HBN Watt Meter Plug with Backlight, Plug-in Socket Power Meter Electricity Usage Monitor Consumption Home Electrical Energy Monitor, Voltage Amps Wattage Electricity Usage Tester, 9 Display Modes
  • ✓ Backlit LCD Display: The watt meter features an upgraded backlit LCD display with a 160° wide viewing angle, providing clear and distinct data readings from any angle, day or night. (Note: To conserve energy, the backlight will automatically turn off after 15 seconds of continuous use.)
  • ✓ 9 Types of Data Display: This energy meter plug accurately monitors a wide range of electrical parameters, including power (W), apparent power (VA), energy consumption (kWh), usage time (hours), power frequency (Hz), power factor (PF), voltage (V), current (A), and electricity cost. The user-friendly interface allows you to easily read and navigate through 9 types of data with a single button.
  • ✓ Save Money and Energy: By toggling through the 9 display modes, you can gain insights into various operational parameters of your devices. The home energy monitor also calculates and displays the electricity consumption and cost over time, helping you save on your electricity bills by monitoring and managing energy usage.
  • ✓ Data Storage: The plug-in electricity meter stores all non-real-time data, ensuring no information is lost in the event of a sudden power outage. If data exceeds the screen’s maximum display range, the screen will flash as a reminder. Pressing and holding the reset button for 3 seconds will reset the cumulative data to zero.
  • ✓ Safe to Use: Rated voltage 125VAC, 60Hz, 15A maximum 1875W resistor and tungsten wire, 1/2HP. Clean and tidy interface, very simple to use.

Home Assistant’s Energy dashboard can combine compatible monitors, smart plugs, solar inverters, utility meters, batteries and instantaneous power sensors. It is a practical route for users who want custom dashboards and local automation, provided the selected hardware has a suitable integration.

Build versus buy

Option Best suited to Main trade-off
ESP32/PZEM prototype Students, makers and developers wanting source-code control. Requires electrical-safety work, calibration, maintenance and secure infrastructure.
Panel-installed commercial monitor Homeowners wanting supported whole-home or circuit-level monitoring. Usually requires professional installation and may depend on a vendor cloud.
Smart-meter-connected monitor Renters or users who cannot access the panel. Depends on utility, meter compatibility and available data.
Home Assistant with compatible sensors Technical users wanting multi-vendor local automation. More setup, integration and maintenance responsibility.
Smart plugs Individual plug-in appliances and simple scheduling. Not suitable for whole-home measurement or fixed high-load circuits.

Commercial alternatives

Emporia’s official product page lists Vue configurations for mains-only and mains-plus-branch monitoring. On the page checked on August 18, 2026, listed prices were $99.99 for mains monitoring, $149.99 for mains plus eight branch sensors and $199.99 for mains plus sixteen branch sensors. Emporia states ±2% measurement accuracy, UL certification, 2.4 GHz Wi-Fi, less than 3 W consumption and a one-year warranty; these are vendor claims. See Emporia’s energy-monitor page.

Emporia says its Vue communicates with the Emporia cloud and does not provide local device access, so it is less suitable for readers who require a local-only, MQTT-first system. Panel installation also needs electrical-safety review.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Emporia’s Vue Utility Connect is a different product: it plugs into a standard 120 V outlet and reads compatible utility smart meters wirelessly. Its shop displayed $39.99 on August 18, 2026, but availability depends on the utility service area and AMI meter. Emporia states that Utility Connect updates approximately every 30 seconds and does not provide circuit-level monitoring. See the Utility Connect documentation and official shop page.

Emporia also markets time-of-use scheduling, EV charging control, peak-demand management and excess-solar management. Those capabilities depend on compatible hardware, connected devices, rates and geography; they are beyond the published ESP32/PZEM code.

Which approach should you choose?

  • Choose the DIY project for learning, prototyping, custom MQTT dashboards and complete firmware control.
  • Choose a smart-meter-connected monitor if you are renting and your utility and meter are supported.
  • Choose a commercial panel monitor if you want a finished app and supported whole-home or circuit-level monitoring.
  • Choose Home Assistant with compatible hardware if local control, vendor flexibility and custom automation matter more than turnkey setup.

Do not use the unmodified prototype as the sole solution for certified electrical protection, accurate utility-bill reconciliation, demand-charge optimization, commercial monitoring, secure remote relay control or complex solar and battery tariffs.

Final assessment

The Smart Energy Bill Optimizer & Real-Time Power Monitor is a useful ESP32/PZEM foundation: it demonstrates live electrical telemetry, cumulative energy measurement, simple cost estimation, MQTT integration and an optional relay response. Its practical value is greatest as an educational or custom-monitoring project.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

It should not be presented as a guaranteed bill-saving appliance. The prototype becomes an optimizer only when it adds a validated tariff model and safely changes load behavior. For fixed wiring or panel installation, treat electrical safety, certification, isolation and professional commissioning as more important than adding another dashboard feature.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

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

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.