Meter PZEM-004 + ESP8266 & Platform IoT Node-RED & Modbus TCP/IP

Introduction: Meter PZEM-004 + ESP8266 & Platform IoT Node-RED & Modbus TCP/IP

About: Share - Learn - Makers. Projects, Articles, #automation, #PLC, #Arduino, #IoT and More PDAControl

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.

http://pdacontrolen.com/installation-node-red-plat...

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.

http://pdacontrolen.com/update-esp8266-industrial-...

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.

http://pdacontrolen.com/electricity-consumption-me...

Step 1: Tests Performed

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

Node-RED

The nodes used in this test have been downloaded and installed, simply search the Node-RED "Manage palette".

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:

  1. empty = Holding Register[0].
  2. Instantaneous voltage = Holding Register[1].
  3. Instant current = Holding Register[2].
  4. Instant power = Holding Register[3].
  5. Accumulated power = Holding Register[4].

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.

http://pdacontrolen.com/meter-pzem-004-esp8266-pla...

Leer Consideraciones, Recomendaciones y sugerencias documentacion Completa del proyecto en Medidor PZEM-004 + ESP8266 & Plataforma IoT Node-RED & Modbus TCP/IP.

http://pdacontroles.com/medidor-pzem-004-esp8266-p...

Share

    Recommendations

    • Creative Misuse Contest

      Creative Misuse Contest
    • Metalworking Contest

      Metalworking Contest
    • Fix It! Contest

      Fix It! Contest

    Discussions