Reading Data Using Modbus RTU Over RS-485

I am working on transmitting temperature data from an E32 module to an E95-DTU. I attempted to send the data in a Modbus RTU structure using the following format:

01 04 02 09 A1 7E D8

However, when I attempt to receive the data, I get the following response:

FB 01 02 09 A1 7E D8

Could you please explain what the "FB" byte signifies? I did not include it in the data I sent. Additionally, I would appreciate guidance on preparing the correct format to ensure successful data transmission.

#include "LoRa_E32.h"
#include <SoftwareSerial.h>

int16_t temperature; 
SoftwareSerial mySerial(3, 2);  
LoRa_E32 e32(&mySerial);


uint16_t calculateCRC(uint8_t *buffer, uint8_t length) {
  uint16_t crc = 0xFFFF;
  for (uint8_t i = 0; i < length; i++) {
    crc ^= buffer[i];
    for (uint8_t j = 0; j < 8; j++) {
      if (crc & 0x0001) {
        crc >>= 1;
        crc ^= 0xA001;
      } else {
        crc >>= 1;
      }
    }
  }
  return crc;
}

void setup() {
  Serial.begin(9600);  

  e32.begin();


void loop() {
 
  temperature = 2465; 

  uint8_t modbusPacket[8];
  modbusPacket[0] = 0x01;  
  modbusPacket[1] = 0x04;  
  modbusPacket[2] = 0x02;  


  modbusPacket[3] = (temperature >> 8) & 0xFF;  
  modbusPacket[4] = temperature & 0xFF;         

  // CRC hesapla
  uint16_t crc = calculateCRC(modbusPacket, 5); 
  modbusPacket[5] = crc & 0xFF;                 
  modbusPacket[6] = (crc >> 8) & 0xFF;         


  e32.sendMessage(modbusPacket, sizeof(modbusPacket));

 
  Serial.print("Sent Packet: ");
  for (int i = 0; i < sizeof(modbusPacket); i++) {
    Serial.print(modbusPacket[i], HEX);
    Serial.print(" ");
  }
  Serial.println();

  delay(1000);
}

I moved your topic to an appropriate forum category @mehmetemin20 .

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

I don't see where your RS485 interface is in the code you posted.


Firstly, thank your response. I am not using RS-485 interface between E32 and E95-DTU.

In which case, you may want to adjust the title of this discussion to better reflect your specific problem.

What is an E32?
What is an E95-DTU?
Is there an Arduino involved somewhere?

You don't just send data in modbus rtu. Client makes request for data and server responds to that. That data you "sent" is a valid modbus response.
Your setup is not clear. Who is client and who is server?