Hi Experts,
Currently, i am trying to read data from the MODBUS sensor through Arduino mega, My problem is if i use serial.write function the Modbus(RS-485) sensor return data then if i use serial print function instead of serial write that sensor return nothing
i have shown my code here for your reference, i was searching in google regarding this but i don't get the reason that's why i ask question to this forum,
Serial.write send Binary data to serial that's why i am used serial print(value, BIN) but i get the same problem,
kindly help to solve this problem.
#include <SoftwareSerial.h>
#define Pin13LED 13
byte byteSend;
void setup()
{
Serial.begin(9600);
Serial1.begin(9600);
Serial.println("MODBUS...");
}
void loop()
{
while (Serial1.available())
{
byteSend = Serial1.read(); // Read the byte
Serial.print("RDATA:");
Serial.println(byteSend, HEX);
}
delay(1000);
byte request[] = {0x01, 0x03, 0x00, 0x75, 0x00, 0x04, 0x55, 0xD3};
int i=0;
for(i=0; i<sizeof(request); i++)
{
// Serial1.write(request*);*
_ Serial1.print(request*,BIN);_
_ //Serial1.println("");_
_ }_
_}*_