0

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()   
{

 Serial.begin(9600);

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


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

  delay(10);


}

byte buf[8];
void loop()
{

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

     Serial.print("DATA:");
    Serial.println(buf[3], HEX);Serial.println(buf[4], HEX);

    delay(1000);

} 
  • 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 – Rahul Jathar 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.