rs485 based on HW-97 module specific query format

Hi,
Trying to use rs485 for sending and receiving data from solar inverter. The message format is for example

8 Bytes key provided by VENDOR

0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX

Example Send : 01 10 90 00 00 04 08 01 00 00 00 00 00 00 00 B6 E7

Receive : 01 10 90 00 04 1C EE

Port settings:

  • Baud rate : 9600
  • Data bits per Byte : 8
  • Parity : None
  • Stop bits : 1

MSG format
The Modbus version used is RTU (mode master/slave).
The Modbus protocols define a format for the master query and the slave response, the DEVICE is defined as the slave for the communication.You must wait for the DEVICE to send a response back or reach the 10s timeout before sending a new command, otherwise you may receive all the response at once.

I need help on my current approach which is not working. Any pointers are much appreciated !

#include <SoftwareSerial.h>

// assemble message
byte msg [] = {
    0x01,
    0x10,
    0x90,
    0x00, 
    0x00,
    0x04,
    0x08,
    0x01,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0xB6,
    0xE7  
};


#define TX_ENABLE_PIN 3 // DE-RE from HW-97 to pin 3 on nano

SoftwareSerial rs485(1, 0); // Arduino NANO

#define RS485Transmit    HIGH
#define RS485Receive     LOW


void setup(){
  pinMode(TX_ENABLE_PIN, OUTPUT);  // driver output enable
  rs485.begin (9600);              
  Serial.begin(9600);
  Serial.println("Setup DONE !");
}

void loop(){    
       // Send data
              Serial.println();
                digitalWrite (TX_ENABLE_PIN, HIGH);     // enable transmit 

                  Serial.print(a);
                  rs485.write(a);
                  
                  for (int i = 0; i < sizeof(msg); i++) {
                      Serial.print(msg[i], HEX);
                      rs485.write(msg[i]);
                      Serial.print(", ");
                  }
                  
                  rs485.flush();
                  Serial.println();
                  digitalWrite(TX_ENABLE_PIN, LOW);       // disable transmit 

                  delay(1000);

    // Try to read back
      Serial.println();
      Serial.write(rs485.read());

  delay(1000); // Wait a while
}

Not very helpful but thanks for your time anyway. :frowning: