SEN0482: how to read ADDRESS REGISTER after failed CHANGE ADDRESS input attempt?

userHead STEFANO60 2024-05-03 18:44:09 285 Views0 Replies

Hello!

I'm succesfully connecting Wind Speed sensor to ESP32 using simple TTL-RS485 converter, without issues.

 

After that, I tried to change the ADDRESS of the Wind Direction sensor SEN0482, and it stopped to answer.

 

I'm trying to debug the issue, and I think the easiest way would be to read the ADDRESS REGISTER (0x10 0x00) using the broadcast station number (0x00) to check the register content (because I do not know the actually stored station number) having only Wind Direction sensor connented to the RS485 bus.

 

Unfortunately, I cannot get any answer.

 

This is the inquiry frame I'm using (8 bytes):

 

0x00 0x03 0x10 0x00 0x00 0x01 0x81 0x1B

 

where:

 

0x00 0x03 = Broadcast station number  + read function code

0x10 0x00 = ADDRESS REGISTER

0x00 0x01 = Register lenght

0x81 0x1B = CRC-16 according to MODBUS (see https://crccalc.com/)

 

and I expect to read: 

 

0x0# 0x03 0x10 0x00 0x00 0x0# CRCHigh CRCLow

 

where:

 

0x0# 0x03 = Receiving station + read function code

0x10 0x00 = ADDRESS REGISTER

0x00 0x0# = stored station number

CRCHigh CRCLOw = related CRC bytes

 

What is wrong with this?

 

Is there any command to force a “factory reset”?

 

Here is my code,

thanks for help!

 

#define RS485_PIN_DIR 5  // TTL-to-RS485 command pin

#define RXD2 16  

#define TXD2 17

#define RS485_WRITE     1

#define RS485_READ      0

byte leggi_frame[] = {0x00, 0x03, 0x10, 0x00, 0x00, 0x01, 0x81, 0x1B};

byte buf_addr[8];


 

void setup()

{

  Serial.begin(115200);

  delay(3000);

  Serial.println("");

  Serial.println("=========================================");

  Serial.println("");

  Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);

  pinMode(RS485_PIN_DIR,OUTPUT);

  digitalWrite(RS485_PIN_DIR,RS485_READ);

  delay(1000);

  digitalWrite(RS485_PIN_DIR,RS485_WRITE);

  Serial.println("Send inquiry");

  Serial2.write(leggi_frame, 8);

  delay(10);

// Reading answer

  digitalWrite(RS485_PIN_DIR,RS485_READ);

  Serial2.readBytes(buf_addr, 8);

  delay(1000);

  Serial.println("");

  Serial.print(buf_addr[0], HEX);

  Serial.print(" ");

  Serial.print(buf_addr[1], HEX);

  Serial.print(" ");

  Serial.print(buf_addr[2], HEX);

  Serial.print(" ");

  Serial.print(buf_addr[3], HEX);

  Serial.print(" ");

  Serial.print(buf_addr[4], HEX);

  Serial.print(" ");

  Serial.print(buf_addr[5], HEX);

  Serial.print(" ");

  Serial.print(buf_addr[6], HEX);

  Serial.print(" ");

  Serial.println(buf_addr[7], HEX);

}


 

void loop()

{ // do nothing

}