Introduction: Meter PZEM-004 + ESP8266 & Platform IoT Node-RED & Modbus TCP/IP
In this opportunity we will integrate our active power meter or electric consumption,Pzem-004 - Peacefair with the IoT Node-RED integration platform used in previous tutorials, we will use an ESP8266module configured as Modbus TCP / IP slave, later we will visualize the measurements in Node- RED Dashboard to visualize the 4 available variables such as active power, accumulated electrical consumption, voltage and current.
Previous Tutorials Recommended
Installation Platform Node-Red
In the following tutorial we will indicate how to install Node-RED for linux and in case of other OS we recommend Virtualbox.
Updating ESP8266 Industrial Modbus TCP IP V2.0
A long time ago I made some tests of ESP8266 as a Modbus TCP/IP slave, the following tutorial can be taken as background information of the current tests.
Electricity consumption meter Peacefair PZEM 004 + ESP8266 & Arduino Nano
If you want to know more about Pzem-004 Peacefair , I recommend the following tutorial:
Features, Arduino connections and ESP8266.
Step 1: Tests Performed
We will measure the electrical consumption of a resistance to heat water, consume approximately 920 Watts and we will visualize the measurements in a dashboard created in Node-RED Dashboard and the communication implemented Modbus TCP / IP.
Step 2: Simple Test Meter PZEM-004 & ESP8266 Platform IoT Node-RED Dashboard Modbus TCP/IP
Active power measurement test or power consumption with Peacefair PZEM-004 Meter and ESP8266 data
transmission and visualization in the IoT Platform Node-RED / Node-RED Dashboard implementing Modbus protocol TCP/IP
Step 3: Materials and Where to Buy Them Very Cheap !!
Step 4: Node-RED
The nodes used in this test have been downloaded and installed, simply search the Node-RED "Manage palette".
- Modbus TCP/IP, Node-RED nodes will be Modbus TCP/IP master
- Node-RED Dashboard, visualization package.
In this case, an Array of 5 positions [0,1,2,3,4] is received, the first position in 0 and the rest contains the values of voltage, Current, Power, Accumulated Consumption.
Using some Script nodes the values are separated and is done doing the inverse of Arduino IDE is divided in 10 the values received to convert them from Int to Float in the required cases, technically all this is done for the correct visualization.
Step 5: Node-RED Dashboard
Step 6: Arduino IDE Code
Arduino IDE Code
The routine created in Arduino IDE, ESP8266 performs the reading of the meter PZEM-004 through the serial port, from previous tests with Modbus TCP / IP a routine was created cut for sending and receiving of Holding Registers.
4 variables have been defined in 4 Holding Registers:
- empty = Holding Register.
- Instantaneous voltage = Holding Register.
- Instant current = Holding Register.
- Instant power = Holding Register.
- Accumulated power = Holding Register.
Quick solution to shipment of Float in Int
The values of the meter are floating type, the Holding Registers are 16-bit Integers, in this case by practicality simply multiplying by 10 we perform the sending of the value, in next tests we will carry out the shipment in 2 integers of 16 bits.
Note: Download and / or github links below.
Step 7: More Info and Downloads
Documentation / Documentación
Read Considerations, Recommendations and Suggestions complete documentation of the project in Meter PZEM-004 + ESP8266 & Platform IoT Node-RED & Modbus TCP/IP.
Leer Consideraciones, Recomendaciones y sugerencias documentacion Completa del proyecto en Medidor PZEM-004 + ESP8266 & Plataforma IoT Node-RED & Modbus TCP/IP.
Participated in the