ePrivacy and GPDR Cookie Consent by TermsFeed Generator Home Automation System - Energy consumption monitor...mqtt protocol | IoT - smartHome | DomoticsDuino - Computer engineer, Smart Home, Flight Sim and others...
IoT - smartHome (181 posts)


Home Automation System - Energy consumption monitor...mqtt protocol

by Marco Lamanna

Here we are again to speak about energy monitor and OpenHAB. I made some step forward with my experiments.

In the previous post I made some tests with the PZEM-004T Energy Module and an Arduino UNO.

The test was OK...and now I would try to replace Arduino UNO with a cheaper Esp8266 NodeMCU.

There are some differences, because Esp8266 NodeMCU works with 3.3V but Arduino works with 5V, as the PZEM-004T Energy Module.

In the previous test I took 5V from Arduino board and so there was no need to use an external supplier. Now with the Esp8266 NodeMCU it's different because it needs 3.3V.

But...my Esp8266 NodeMCU is a particular model, called LoLin and can be powered with 5V through microUSB cable and it has an output pin with the same voltage as main power.

So, I will use an old power supplier which provides 5V and 400mA.

Let's plug all together.

Last step: the software

Let's use the same software used for Arduino, just to check the everything works well.

Here is the serial output.

18W lamp:

100W lamp:

It's all OK...nice!

Let's edit the software to introduce MQTT protocol. This is the idea: if energy values are similar, I will send the data every 1 minute; otherwise, when a value differs from the previous one, send the data immediately.

This is my MQTT topic (just for testing purpose)


using MQTT-SPY I check the transmission:

All work as expected...

My next job will be to integrate this device with OpenHAB and see the data on its sitemap and on Grafana dashboard