Pages: [1]   Go Down
Author Topic: Connecting electrical meter Orbis domotax to arduino mega, help!  (Read 904 times)
0 Members and 1 Guest are viewing this topic.
Spain
Offline Offline
Newbie
*
Karma: 0
Posts: 32
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Code:
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);   
}
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 67
Posts: 3701
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'd suggest trying it with write instead - print is sending your data as text and will drop all leading zeros. Do you have a link to the documentation?
Logged

Spain
Offline Offline
Newbie
*
Karma: 0
Posts: 32
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have the datasheet of Domotax but in Spanish. I could leave you the manufacturer´s web but the documentation there is no there, it seems they have erased.

http://www.orbis.es/ficha_producto.aspx?inPkyIdi=1&inPkyPro=16

 this is the data format to be sent:  STX LEN ORDEN NUM_ABONADO datos BCC ETX

Where STX is a uchar and its value is 0x02

LEN is a uchar and it´s the number of bytes counted from STX to ETX.

ORDEN is a uchar, it´s the command to be processed

NUM_ABONADO is a LONG with the internal number of device

datos is a bytes array( uchar), variable, the values depends on the command. The maximum length is 200bytes in receiving and transmiting mode.


BCC is a uchar and it´s the arithmetic add of bytes from STX to BCC. Including STX ,excluding BCC and ETX

ETX is a  uchar and its value 0x03
Logged

Spain
Offline Offline
Newbie
*
Karma: 0
Posts: 32
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi again!

I´ve changed print for write and it seems that the electrical meter receives the data because in its LCD the word Rx turns on when I send the data, but it must be something wrong because the word Tx does not turns on because it seems the meter does not interpret the data received.
Some help with that?
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 67
Posts: 3701
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just guessing, but are you sure you have the byte order correct in NUM_ABONADO? May be some endian issues to deal with there. Even if the ID were wrong though, I'd hope to get an error response. Have you tried any other commands?
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 67
Posts: 3701
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Actually, realizing that it's RS-485 and thus a bus, I would not expect any response from providing an incorrect device address.
Logged

Spain
Offline Offline
Newbie
*
Karma: 0
Posts: 32
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, the NUM_ABONADO is correct, and I´ve tried with another commands but the same, no response. I don´t know what to do yet.
Logged

Pages: [1]   Go Up
Jump to: