Hi to all,
I’m trying to connect via RS485 an Arduino Uno Aurora PV inverter that I have installed on my PV system at home.
For the connection of devices I have used the schema-model in the link below.
So I connect the arduino One’s GRND to the GRND of the inverter; the TX and RX pins of the Arduino to the corresponding outputs of the inverter and the PIN 2 for the transmission of the message.
About the form of the message, the Aurora inverter accepted formalism is described in trasmissionMessage.jpg and receivingMessage.jpg in attach.
The actual code is the following:
Code:
byte RFin_bytes[9];
#define pinTx 01
#define pinRx 00
#include <NewSoftSerial.h>
void setup()
{
pinMode(pinTx,OUTPUT);
pinMode(pinRx,OUTPUT);
digitalWrite(pinTx,HIGH);
digitalWrite(pinRx,LOW);
pinMode(2,OUTPUT);
Serial.begin(9600);
}
void sendMSG(byte address,byte command,byte b2,byte b3,byte b4,byte b5,byte b6,byte b7,byte crc_l,byte crc_h)
{
Serial.write(12345);
//Generic command call
Serial.write(command);
Serial.write(b2);
Serial.write(b3);
Serial.write(b4);
Serial.write(b5);
Serial.write(b6);
Serial.write(b7);
Serial.write(crc_l);
Serial.write(crc_h);
delay(100);
//After trasmission PinTx is set LOW
digitalWrite(pinTx,LOW);
}
void loop()
{
delay(500);
digitalWrite(pinTx,HIGH);
//Begin trasmission with request to Inverter
if (pinTx==HIGH)
{
//Inverter state request
pinMode(2,OUTPUT);
sendMSG(12345,50,0,0,0,0,0,0,1,2);
delay(50);
//Inverter state response
pinMode(2,INPUT);
while (Serial.available()<8) {} // Wait 'till there are 9 Bytes waiting
for(int n=0; n<8; n++)
{
RFin_bytes[n] = Serial.read(); // Then: Get them.
//here I have to recognize the specific answer of the inverter, reading byte by byte the message -- to be defined
}
}
//Inverter Mesure request
pinMode(2,OUTPUT);
sendMSG(12345,59,0,0,0,0,0,0,1,2);
delay(50);
//Inverter measure response
pinMode(2,INPUT);
while (Serial.available()<8) {} // Wait 'till there are 9 Bytes waiting
for(int n=0; n<8; n++)
{
RFin_bytes[n] = Serial.read(); // Then: Get them.
//here I have to recognize the specific answer of the inverter, reading byte by byte the message -- to be defined
}
}
So, as yoou can see, I’m trying first to send request commands and then, reading the answer byte by byte, to recognize the answer of the inverter.
Tahnk in advance to anyone can help me in my project.
Kind regards,
Gerry