Hello all,
I'm trying to read from the RS485 port of an Electricity Meter using an Arduino Nano, using a MAX485 chip to convert to RS485 to TTL.
It uses the IEC 62056-21 protocol, and I'm having trouble receiving anything back from it. I'd appreciate any help, insights or pointers you may have.
I've done a lot of digging but most of it involves reading through an optical port, while I'm using RS485.
I'm attaching a wiring diagram; it's pretty straightforward, with the MAX485 connecting to the VCC, GND and 4 digital pins of the arduino.
Here is the code I'm using. Once again, pretty basic. Setting DE and RE to HIGH, sending the "/?!" signal, then setting DE and RE to LOW and waiting for a response.
// Print RS485 data to serial
// Connections:
// DI = 2, DE = 3, RE = 4, R0 = 5
#include <SoftwareSerial.h>
SoftwareSerial SSerial(5, 2);
void setup(void){
// initialize serial port
Serial.begin(115200);
delay(10);
Serial.print("\nInitializing");
while (!Serial) { delay(10); Serial.print("."); }; // wait for serial port to connect. Needed for native USB port only
Serial.println("\nReady");
// initialize RS485 connection
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
SSerial.begin(300);
Serial.println("Sending Initial Message");
digitalWrite(3, HIGH); digitalWrite(4, HIGH);
SSerial.write("/?1!");
digitalWrite(3, LOW); digitalWrite(4, LOW);
Serial.println("Waiting for response...");
}
void loop()
{
while(SSerial.available())
{ Serial.write(SSerial.read()); }
}
I've tried sending different variations of the message, like /?1! or /?1!\r\n.
I've also tried putting a delay after the write, before switching the pins to low.
But no matter what I've tried, I haven't received anything back.
Perhaps I'd have better luck connecting the MAX485 to something like a FT232 (USB to TTL) and try communicating to the device directly with my electric meter using the serial monitor?
(The end goal is to use an ESP8266 instead of an Arduino, but I'd like to actually get it working first before taking that step.)
Any help would be appreciated!