ESP8266 NodeMCU – Simple IOT energy meter using Blynk APP

In this tutorial we will learn how to make a simple, single phase, IOT energy meter, where you can see the value in real time in your android phone. If you want to know how to work with the mesurement circuit, and how to acquire the eletrical values, check the “ESP8266 NodeMCU – Simple energy meter using PZEM004T”

Blynk Android app

Blynk is a hardware-agnostic IoT platform with white-label mobile apps, private clouds, device management, data analytics, and machine learning. You should check their Website to know more about Blynk.

Figure 1

So to install and configure the app, you must follow the tutorial in their website. However if you follow the blynk tutorial, you will end up using the server. The server is a good option because, is safe, continuous and fast. Although server is currently providing 2.000 of energy, which limit your Dashboard. To solve this problem, you can use public free blynk servers, from this GitHub. Remember that this servers are unreliable and can have intermittent shutdown. I will use the second server, but you can use any of them.

To change the server for the, in the login in page of the app, when choosing the server, you need to click on the “3 dots” botton and copy the server name and App port, as shown in figure 2.

Figure 2

Affter making the instructions above, you will receive an email with a token. We will use that token in the code for access to the server. To beggin, creat a new project and name it as you desire. In this tutorial, it will be “Meter”.

Figure 3

Below the project name, you need to especify the hardware. Choose the ESP8266 option.

Figura 4

Since, this is a energy meter the dashboard will show the main variables of an eletrical instalation, like in the list bollow. It will also have a button, if you want to switch the meter on and off. You can see the general layout in figure 5.

  • Voltage (V);
  • Corrent (A);
  • Power (W);
  • Power factor (Cos_fi);
  • Reactive Power (VAr);
  • Mouth Energy (kWh).
  • Temporal graph, to see the past values.
Figure 5

To configure the widgets, press them and a menu will apeer. The botton options and the pin type can be seen in the the figure 6. The botton is a way to turn the system on and off. Use the virtual pin V6

Figure 6

The values of the eletrical parameters are shonw in a “Value Display Settings” and the configurations can be seen in the the figure 7. Since these values are obteined from the PZEM, they are not digital nor analog. Thus we must connect them to the virtual pin V0 of blynk with a reading rate “Push”

Figure 7

Last but not least, we can use the graph to display the electric variables in time. Give a title to the graph and intruduce a “Datastream” per value that you want to display. Those are the values from the visual pin choosen acordingly to the variables from PZEM004T. For exemple, in figure 8, you can see the configuration of the voltage “Datastream”. Choose the virtual pin V0 and specify the suffix and the decimals. For the current “Datastream” choose the virtual pin V1 and make the same. Continue to include “datastreams” as much variables you have in the code.

Figure 8


We will use a library from Git-Hub, that communicate with PZEM004T, and manipulate it to send the values to our blynk app. We also need a library for wifi conection with If you do not know how to instal a library or use the library manager in arduino IDE, you can check Installing Additional Arduino Libraries. The Blynk library and EPS8266 library must also be included by you. Copy the main sketch bellow to your Arduino IDE project and save it. Have fun!!

Note: NodeMCU only have one Serial Port. Because of that, we need to use software serial in order to prevent colision while downloading the code.

Leave a Reply

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