Introduction
The ESP32 PLC 14 with the Powermeter expandable module features real-time monitoring of electrical parameters across a three-phase system. The setup involves three live (phase) lines—Line 1 (L1), Line 2 (L2), and Line 3 (L3)—and one neutral (N) line, making it suitable for monitoring and controlling three-phase electrical loads.
The Powermeter plays a critical role in measuring key parameters such as voltage, current, power factor, energy consumption, and other electrical metrics from each of the three live lines relative to the neutral. These parameters can be monitored through the PLC, allowing for efficient automation, fault detection, and energy management within the system.
This integration enables real-time data collection and analysis, making the setup ideal for applications in industrial automation, power distribution monitoring, or any environment where accurate energy usage and system performance are critical.
Communication Protocol
The Powermeter module is based on the MSP430F6779IPEU SoC. This chip is in charge of reading all measures and updating its registers to be read afterwards. To read them, 2 communication protocols can be used: I2C or RS-232. To use them, modify the code depending on the desired protocol:
- I2C:
- RS-232:
Depending on the mode, the available communication will be I2C or RS-232. The internal ESP32 CPU I2C bus can be used, or even an external one with the use of the designed I2C pins located at the side of the PLC. For RS-232, use the DB9 connector on the top of the ESP32 PLC 14.
Industrial Shields has developed an I2C library for easy intercommunication with the Powermeter module, but not all available tools are included. For a full understanding of the Energy Measurement Design Center (EMDC) communication protocol, which is the protocol the chip works with, refer to its Communication Protocol Spec.
Software approach
To use the Powermeter module, you will need to download the following files and store them inside the same directory as your project code, or under Arduino/libraries/Powermeter.
The example code is the following:
The code does the following:
- It starts the Serial port and I2C.
- We print a total of 27 "A", and then we move the cursor 28 rows up. this allows to write on top of the already printed characters, and this will very useful when printing all the read data.
- After the initialization, we start reading from the I2C bus the parameters from all channels (A, B, C) which are the 3 live lines on the PLC. After printing everything, we again move the cursor back on the top to print again.
As it can be seen in the above captures, on the left image there is nothing connected to the live lines, so every relevant value is 0. When the A channel is connected (right image), we can clearly see how the VRMS A is set to 243.071V, and all parameters referring channel A have its correspondent value.
Using the Powermeter module with ESP32 PLC 14