Hi
I've converter RS485 to UART Breakout Auto direction. There's only 4 pins vcc, gnd, RXI and TXO. Arduino communicates with the device in one direction OK (board change value), but received data are wrong. When I send for instance. A1 02 64 07 answering is the same a1 02 64 07 and should be a1 03 64 08.
This is my beginnings with rs485 my code: #include <SoftwareSerial.h>
SoftwareSerial mySerial(0, 1); // RX, TX
int in;
int out;
void setup()
{
Serial.begin(9600);
mySerial.begin(9600);
}
void loop()
{
if (Serial.available())
{
out = Serial.read();
mySerial.write(out); // Send byte to Remote Arduino
delay(10);
}
if (mySerial.available()) //Look for data from other Arduino
{
in = mySerial.read(); // Read received byte
Serial.write(in); // Show on Serial Monitor
delay(10);
}
Which is garbage. You can NOT do SoftwareSerial on the hardware serial pins at the same time as you do hardware serial. If you are not actually using the Serial instance, then you most certainly SHOULD be using it, instead of SoftwareSerial.
PaulS:
Which is garbage. You can NOT do SoftwareSerial on the hardware serial pins at the same time as you do hardware serial. If you are not actually using the Serial instance, then you most certainly SHOULD be using it, instead of SoftwareSerial.
@PaulS,
There were so many inaccuracies with the OP's post, I don't know why you bothered. I did not even want to ask how his 'automatic' RS485 was wired. No schematic was supplied, the code would not work.
PaulS give me good advise "You can NOT do SoftwareSerial on the hardware serial pins at the same time as you do hardware serial". Now I can send and read data. Thanks.