Send and Receive HEX serial Arduino as Modbus Slave Sensor

Hello everybody.. :slight_smile:

I'm trying to make Modbus RTU communication protocol in Arduino. I use the Arduino Mega ADK. but I have problems in making a program on arduino as a slave. I've made a VB.NET program as a master to request data from the Arduino.Data sent in hex format 110340000006D298 and I try to return the same data to my vb program. but when I try to send a request through Hterm serial monitor, Arduino reply in ascii. Can anyone help me to improve this program?

 byte buffer[8];


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

  void loop()
  {
    unsigned long startWait = millis();
    while(Serial.available() < 8 )
    {
        
      
    }

    // At this point, there are 8 characters 
    if(Serial.available() >= 8)
    {
       for (int i=0; i< 8; i++)
       {
          buffer[i] = Serial.read();
       }

       
       Serial.write(buffer,8);
       Serial.println("");
      
    }
    else
    {
        
    }
      
             
  }

but when I try to send a request through Hterm serial monitor, Arduino reply in ascii.

If the write from the Arduino is in ASCII, then the Arduino must've received ASCII