I am unable to simulate and see the result right now; I hope if the library functions properly this might be a communication issue. I can add a one step debug for you to check and see what is happening.
Your device is acting as a Modbus RTU slave, So take another Arduino, make it act it like a master device, and see what response is coming from the slave device.
Here is a glimpse of code I used to make arduino as a master and see the response coming in Serial terminal.
#include <SoftwareSerial.h>
#define rxPin 2
#define txPin 3
#define RS485_pin 10
//SoftwareSerial mySerial(rxPin, txPin);
#define mySerial Serial1
byte test_data[8] = {0x01,0x03,0x00,0x64,0x00,0x02,0x85,0xD4};
int data_count = 5;
byte rcvdata[15];
int param_value_int[7];
void setup() {
// put your setup code here, to run once:
//mySerial.begin(19200,SERIAL_8E1);
mySerial.begin(9600);
Serial.begin(9600);
delay(1000);
pinMode(RS485_pin, OUTPUT);
digitalWrite(RS485_pin,LOW);
delay(100);
}
int count = 0;
void loop() {
if(count%10 == 0) {
Serial.println();
send_data();
}
count++;
while(mySerial.available()>0)
{
byte b=mySerial.read();
delay(1);
Serial.print(b,HEX);
Serial.print(" ");
}
//Serial.println(count);
while(Serial.available())
{
digitalWrite(RS485_pin,HIGH);
byte a=Serial.read();
delay(1);
mySerial.print(a);
digitalWrite(RS485_pin,LOW);
// Serial.print(a);
}
delay(1000);
//while(1);
}
void send_data() {
Serial.println("send data");
digitalWrite(RS485_pin,HIGH);
delay(1);
for(char i=0;i<8;i++){
mySerial.write(test_data[i]);
delay(1);
Serial.print(test_data[i],HEX);
Serial.print(" ");
}
Serial.println();
digitalWrite(RS485_pin,LOW);
delay(1);
}
Here you can use Software Serial or normal Serial1 or Serial2 on devices like Mega. Make sure if it is RS485 based you have to toggle the RS485 read-write pin each time to enable and disable one feature at a time as RS 485 uses half-duplex communication.
In this case test_data[] uses Function code FC03 Read holding register. You can make your custom data. I am assuming you are familiar with all the types available.Still there is a great site [ link ] to look up to if you don't know the basics. The last two bytes are checksum. And there is an online checksum calculator available if you need also
https://www.lammertbies.nl/comm/info/crc-calculation.html
In this way you can at least debug and share the result, so that we can help more.