1
I made a sketch for Arduino MEGA, where receives data by Serial2 and displays in Serial, the communication happens but the byte sent is not the same as the received, for example:
Send 0x01, receive 0x7F Send 0x99, receive 0x33
void setup()
{
Serial.begin(9600, SERIAL_8N1); //Monitor
Serial2.begin(9600, SERIAL_8N1); //Leitor
Serial.println("Waiting...");
}
void loop()
{
byte data;
if ( Serial2.available() ) {
Serial.println("Leitor...");
do {
data = Serial2.read();
Serial.print("0x");
Serial.println(data, HEX);
} while (Serial2.available());
}
}
I tried to change the configuration to 8N2, 7N1 among others but the serial sending as in the image below:
It is not the first time that I try to read something by another MEGA serial that is not zero and the same happens.