DEV Community

Cover image for Smart Energy Meter Using IoT with MQTT & SMS Alerts (ESP32 + PZEM-004T)
David Thomas
David Thomas

Posted on

Smart Energy Meter Using IoT with MQTT & SMS Alerts (ESP32 + PZEM-004T)

Ever wondered how much power your home actually consumes in real time?

Not just the monthly bill, but live voltage, current, and power usage while things are running. That’s where this project comes in. It’s a Smart Energy Meter Using IoT that gives you real-time data and even sends alerts when something goes wrong.

No bulky setup.

No complicated hardware.

Just an ESP32, a PZEM module, and a clean IoT workflow.

Pzem Module with CT

What This Project Does

At its core, this system tracks electrical parameters like voltage, current, power, and power factor.

It sends this data to an MQTT dashboard so you can monitor everything remotely. And when something abnormal happens, like high voltage or unusual current, it sends an SMS alert straight to your phone.

That extra layer of safety makes this more than just a monitoring tool.

It feels like a smart watchdog for your home.

Why PZEM-004T Makes Things Easy

Current Transformer

If you’ve worked with voltage or current sensors before, you know calibration can get messy.

The PZEM-004T solves that.

It’s factory-calibrated and handles all the heavy calculations internally. You just connect it and start reading accurate values without spending hours tuning things.

It measures voltage, current, power, energy, frequency, and power factor all in one module.

For most DIY builds, that’s more than enough.

How the System Works

Circuit Digaram of Energy Meter

The setup is actually pretty clean once you break it down.

The PZEM module reads electrical data from your mains line using a current transformer. The ESP32 communicates with it over UART and collects all the values.

From there, two things happen at the same time.

The ESP32 publishes data to an MQTT broker for remote monitoring. At the same time, it displays readings locally on an LCD.

And if a condition like high voltage is detected, it triggers an SMS alert.

Simple flow, but very effective.

MQTT Makes It Feel Real-Time

Instead of using traditional HTTP requests, this project uses MQTT.

That’s a big deal.

MQTT works on a publish-subscribe model, so data gets pushed instantly instead of being requested repeatedly. This means lower latency and smoother updates.

In practice, it feels like live streaming your electrical data.

No delays.

No refresh needed.

Hardware Setup

The hardware side is pretty straightforward.

You connect the PZEM module to the ESP32 using TX and RX pins. The LCD uses I2C, so only two wires are needed for data.

The CT clamp goes around the live wire to measure current.

That’s it.

The rest is just powering everything properly and making sure connections are clean.

Code Logic (What’s Happening Inside)

The ESP32 continuously reads values like voltage, current, and power from the PZEM module.

These values are then sent to the MQTT broker and displayed on the LCD.

At the same time, the code checks for abnormal conditions. For example, if voltage crosses a certain limit, it triggers an SMS alert.

There’s also a cooldown system in place.

This prevents multiple alerts from being sent repeatedly for the same issue.

Real-Time Monitoring Experience

Once everything is running, you can see your data in multiple places.

On the LCD for quick local viewing.

On the serial monitor for debugging.

And on the MQTT dashboard for remote access.

All three show the same data in sync.

It’s actually satisfying to watch your system behave like a proper IoT device.

Where This Can Be Used

This kind of setup fits into a lot of real-world scenarios.

You can use it at home to monitor power consumption and detect faults early. You can use it in small industrial setups where basic monitoring is needed without expensive systems.

Or even in remote locations where you just want alerts when something goes wrong.

That’s where the Smart Energy Meter Using IoT idea really shines.

It doesn’t just show data.

It tells you when something needs attention.

Troubleshooting Tips

If current always shows zero, the CT clamp is usually the issue.

Make sure it’s properly closed and placed only on the live wire. Clamping both live and neutral will cancel the measurement.

If the LCD doesn’t show anything, check the I2C address and wiring.

And if values look weird, double-check the UART connections between ESP32 and the PZEM module.

Small mistakes here can throw off everything.

Why This Project Feels Practical

A lot of IoT projects look good on paper but don’t feel useful in real life.

This one is different.

You’re actually monitoring something important, and the system reacts when something goes wrong. It’s simple enough to build, but powerful enough to be useful.

That balance is what makes this a solid engineering project.

Top comments (0)