I am interfacing Amonia Sensor RS485 output with Arduino Mega but not getting any response. i need to transmit {0x06, 0x03, 0x00, 0x00, 0x00, 0x04, 0x45, 0xBE}; frame to sensor then senor will send response frame. i am using Max485 converter which has DE RE pins .could you guide ME to write proer code. please help me i am in trouble

#include <SoftwareSerial.h>

#define SSerialRX        0 
#define SSerialTX        1  

#define modbusModuleDE   8
#define modbusModuleRE   9

SoftwareSerial RS485Serial(SSerialRX, SSerialTX);
byte byteSend;

//ModbusMaster node;

void setup()   


 pinMode(modbusModuleRE , OUTPUT); 
 pinMode(modbusModuleDE , OUTPUT);  

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



byte buf[8];
void loop()

     Serial.print("NH: ");   
digitalWrite(modbusModuleDE, 1);
 digitalWrite(modbusModuleRE, 1);   
     byte request[] = {0x06, 0x03, 0x00, 0x00, 0x00, 0x04, 0x45, 0xBE}; 
     RS485Serial.write(request, sizeof(request));
  digitalWrite(modbusModuleDE, 0);
 digitalWrite(modbusModuleRE, 0);  
     RS485Serial.readBytes(buf, 8);

    Serial.println(buf[3], HEX);Serial.println(buf[4], HEX);


  • help you with what? ... you said nothing about any problem
    – jsotola
    Dec 14 '19 at 9:05
  • arduino coding . i wan to transmit data frame to my sensor {0x06, 0x03, 0x00, 0x00, 0x00, 0x04, 0x45, 0xBE}; then sensor will send me its value. i am not able send proper command through arduino master. can check my code @jsotola Dec 14 '19 at 9:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.