Basic UART Using Two Arduino R4's

I am currently testing the UART on my boards to ensure they are in working order, but I do not see any response from the receiving board on the serial monitor. My code and boards are setup like this:

Sending Code:

void setup(){
  Serial.begin(9600); //initialize serial communication at a 9600 baud rate
}

void loop(){
  Serial.println("Hello world!");
  delay(1000);
  
}

Receiving Code:

char incomingByte ; // for incoming serial data

void setup() {
  Serial.begin(9600); //initialize serial communication at a 9600 baud rate
}

void loop() {
  // send data only when you receive data:
  if (Serial.available() > 0) {
    // read the incoming byte:
    incomingByte = Serial.read();

    // say what you got:
    Serial.print("I received: ");
    Serial.println(incomingByte);
  }
}

I am very new to Arduino and cannot find much about UART and the R4.

Thanks.

You might want to try Serial1. Serial is the USB connection.

1 Like

https://docs.arduino.cc/tutorials/uno-r4-wifi/cheat-sheet/

Use CTRL+F, type in Serial and start reading at about instance 17 from that find window.

1 Like

You're a life saver! I did not realize that there was a difference.

2 Likes

Got it working? Excellent. On many boards the serial connection on pins 1 and 2 is distinct from the the USB connection. You'll likely find that being able to have stuff connected to the Rx and Tx pins and still be able to upload new code is very helpful at times.