Hello,
I am trying to read data using Arduino Mega from PZEM-017. DC 0-300V , 0-300A.
It uses MODBUS RTU Protocol to communicate
Baud rate 9600, 8 data bits, 2 stop bits, no parity
It is working fine with its software (Picture attached) on Windows using USB to RS485 converter supplied along with meter
I have connected the meter to Arduino Mega using TTL-RS485 Converter
Wiring Sequence as Follows
Arduino Pin 14 Txd to Pin DI on Converter
Arduino Pin 15 Rxd to Pin RO on Converter
Arduino Pin 48 to Pin DE on Converter
Arduino Pin 49 to Pin RE on Converter
Converter Pin A to PZEM Pin A
Converter Pin B to PZEM Pin B
Arduino, TTL-RS485 Converter , PZEM Meter 5V and Ground is common
Code as below
#define MAX485_DE 48
#define MAX485_RE_NEG 49
int readdata[]={0xF8,0x04,0x00,0x00,0x00,0x08,0xE5,0xA5};
int response[21];
int i;
void preTransmission()
{
digitalWrite(MAX485_RE_NEG, 1);
digitalWrite(MAX485_DE, 1);
}
void postTransmission()
{
digitalWrite(MAX485_RE_NEG, 0);
digitalWrite(MAX485_DE, 0);
}
void setup()
{
pinMode(MAX485_RE_NEG, OUTPUT);
pinMode(MAX485_DE, OUTPUT);
Serial.begin(9600);
Serial3.begin(9600,SERIAL_8N2);
preTransmission();
}
void loop()
{
{
preTransmission();
for (i=0;i<8;i++) Serial1.write(readdata[i]);
delay(50);
postTransmission();
if (Serial3.available())
{
for (i=0 ; i<21;i++)
{
while(!Serial3.available());
response[i]=Serial3.read();
}
}
for (i=0;i<21;i++) {Serial.print(response[i],HEX); Serial.print(' '); }
Serial.println(' ');
delay(2000);
}}
The result is attached
I used Advanced Serial Port Monitor to check communication between Software on PC and PZEM meter
The snapshots are attached
It is working with other Softwares as well like Modbus Poll
But I can't seem to get anything in reply from meter through Arduino. I tried adding removing delays but nothing works



