Hello, I am trying to read in data from modbus rs485 rtu to my arduino mega and output in my PC serial monitor. However, the only thing that outputs is -1. Any guidance is always appreciated.
I have the RS485 to TTL converter found here RS422 / RS485 to TTL Converter / TTL Repeater (Industrial) – CommFront connected to a pressure transmitter that outputs rs485, RTU. My current wiring diagram is as follows (sorry for the bad drawing).
My code is as follows
int b = 0;
void setup()
{
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
Serial1.begin(9600); // open serial port1 for reading in (rx1, tx1 pins)
Serial.println("Starting!");
}
void loop() {
if (Serial1.available() > 0) { //check serial1 port, if i comment out this if statement thats how i get -1
Serial.println("The data recievied is: ");
b = Serial1.read();
Serial.println(b);
}
}