The PZEM-017 is a digital multi-meter manufactured by PeaceFair, designed to measure voltage, current, power, and energy consumption in electrical circuits. This versatile component is widely used in monitoring systems for renewable energy sources, industrial machinery, home energy management, and other applications where precise electrical measurements are crucial.
Pin Number | Function | Description |
---|---|---|
1 | V+ | Positive voltage input for power supply (DC 7-12V) |
2 | V- | Negative voltage input for power supply |
3 | RS485 A | RS485 communication line A (non-inverting) |
4 | RS485 B | RS485 communication line B (inverting) |
5 | NC | No connection |
6 | IN+ | Positive input for voltage measurement |
7 | IN- | Negative input for voltage measurement |
8 | Shunt+ | Connection to the positive side of the external shunt |
9 | Shunt- | Connection to the negative side of the external shunt |
#include <ModbusMaster.h>
// Instantiate ModbusMaster object
ModbusMaster node;
void setup() {
// Initialize Modbus communication baud rate
Serial.begin(9600);
// Set slave ID of the PZEM-017
node.begin(1, Serial);
}
void loop() {
uint8_t result;
// Read 10 registers starting at 0x0000 (Voltage, Current, Power, etc.)
result = node.readInputRegisters(0x0000, 10);
if (result == node.ku8MBSuccess) {
// Process the received data
float voltage = node.getResponseBuffer(0x0000) / 10.0;
float current = node.getResponseBuffer(0x0001) / 100.0;
// Add additional processing for power and energy
// Print the measured voltage and current
Serial.print("Voltage: ");
Serial.print(voltage);
Serial.println(" V");
Serial.print("Current: ");
Serial.print(current);
Serial.println(" A");
}
// Wait for a short period before reading again
delay(1000);
}
Note: This example assumes the use of a RS485 to TTL converter connected to the Arduino's serial pins. The ModbusMaster
library is used for Modbus RTU communication. Ensure that the library is installed in your Arduino IDE before uploading the code to the Arduino UNO.
Remember to adhere to the 80 character line length limit for code comments, wrapping text as necessary.