Hi everybody, this is my first topic here so please, sorry if it exists any error.
Well, my problem is that I have a digital electrical meter (orbis domotax) and I want to connect it to my Arduino Mega trough its serial port (Serial2). The digital meter communicates via RS485, so I have connected Arduino and the digital meter trough a MAX485, to convert the signal from a Serial port to RS485. The problem I have is where I try to communicate arduino and the digital meter i have no response from the meter, I dont have so well how i must send the data to the meter, if i have to do it with "print" or "write".
I leave my program where i send only one instruction for any suggestions.
Thanks.
String received="", txtMsg="";
void setup(){
pinMode(2,OUTPUT);
pinMode(3,INPUT);
Serial2.begin(9600);
Serial.begin(9600);
digitalWrite(2,HIGH); //signal control of MAX485 (pins 2 and 3)
Serial2.print(02); // i want to send (002019034131076076000048048048048048048048048048048050003)
Serial2.print(19); // in decimal format
Serial2.print(34);
Serial2.print(131);
Serial2.print(76);
Serial2.print(76);
Serial2.print(00);
Serial2.print(48);
Serial2.print(48);
Serial2.print(48);
Serial2.print(48);
Serial2.print(48);
Serial2.print(48);
Serial2.print(48);
Serial2.print(48);
Serial2.print(48);
Serial2.print(48);
Serial2.print(50);
Serial2.println(03);
digitalWrite(2,LOW);
delay(1000);
}//setup
void loop(){
while(Serial2.available()){
char c = Serial2.read();
received.concat(c); //store characters to string
Serial.println(received);
}
delay(3000);
}