Originally this test is performed in June 2018 in less than one year, for reasons of availability do not publish, technically just missing the documentation, then I will present the results, well they say there is better late than never.
In this opportunity our PZEM-004 meter or it is also possible with our PZEM-004T communication with the Node RED platform through an Arduino Nano implementing the Modbus RTU protocol on RS232.
Materials and where to buy them Cheap
- Arduino Nano
- New Arduino Nano MicroUSB
- Meter PZEM 004 with display
- Meter PZEM 004T & Three Phase meters
- Meter PZEM-016 Modbus RTU + Serial ConverterRS485-USB+ CT (0-100A)
- Heating resistance
- Module Serial RS232 a TTL
- Wire USB-Serial RS232
Other Recommended Devices
- Transformer core splitter
- Monophasic Electric Consumption Meters – Per Pulse
- Voltage transformers for insulation
- MPPT Controller Regulator for solar panel
- Solar Panels 10W 18v
- Matrix Led x4 Max7219
Recommended tutorials
This implementation works similar to our current tutorial, I recommend seeing them before.
Other recommended
Modbus RTU
In this opportunity we will use one of the most famous protocols in the industry for its practicality and implementation in industrial automation, this case our Arduino will be a slave Modbus RTU serial on physical layer RS232.
Tests
We will measure the electrical consumption of a resistor 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 RTU over RS232.
Arduino IDE
We have used an Arduino Nano, since it is small and practical. To facilitate the sending of floating values in whole registers, some operations are performed in arduino and in Node RED, they are multiplications and divisions among 10.
The Modbus Slave library for Arduino and the library for reading PZEM meters will be used. 2 routines have been created.
Routine 1 performs the reading of PZEM-004 meter values by TTL serial port.
Routine 2 performs the sending of measurement data using Modbus slave library and communication with the Modbus master (Node-RED).
Connections
- Port: Serial Pins(Rx-Tx)<——–>(Tx-Rx) PZEM-004 o PZEM-004T
- Port: SoftwareSerial (Modbus) Pins (D9 – D10)<—–>(Max232)
Node-RED
In this case, the Node-RED platform runs on my PC, as it is serial communication, with an RS232-USB serial converter.
- Nodes modbus: node-red-contrib-modbus, nodes, Modbus RTU/TCP
- Nodes Node-RED Dashboard, display package.
- Configuration Node Modbus RTU, reading 5 Holding Registers, from address 9.
Node-RED Dashboard
Final test result
Complete video
Conclusions
This test was performed to analyze or provide the possibility of using the PZEM-004 meter as a Modbus RTU Node or slave, allowing it to be integrated into basic industrial applications, for measuring electricity consumption from a PLC / HMI or SCADA controller.
Given that according to our experience the modbus protocol in general is very practical and technically all controllers have implemented it for its simplicity and robustness.
This application could also be done with a raspberry pi that has Node RED running.
Downloads
- Code Example Arduino IDE: Modbus_RTU_PZEM_Ard
- Modbus RTU libraries Slave for Arduino
- Node-RED import example