Does Serial1 on UNO R4 Wifi work?

Hi,

I wanted to use the Serial1 port on the R4 for a project but I seem to be getting gibberish from it…

to test, I connected Serial1 Tx/Rx from a MEGA to the Serial1 Tx/Rx on the R4

linked the grounds between the 2 boards.

R4 code:

void setup() {
  Serial.begin(115200); 
  Serial1.begin(19200);
  Serial.println("READY");
}

void loop() {
  if(Serial1.available()){
    Serial.println(Serial1.read());
  }
}

MEGA

void setup() {
  Serial.begin(115200); 
  Serial1.begin(19200);
  Serial2.begin(19200);
  Serial.println("READY");
}

void loop() {
  for (uint8_t i = 0; i < 12; ++i) {
    Serial1.write(i);
    delay(10);
    if(Serial2.available())Serial.println(Serial2.read(),HEX);
  
  }  // put your main code here, to run repeatedly:
  delay(100);
}

Connected Tx Serial1 to Rx Serial2 on MEGA to check is the expected values where being tx’s corrected from Serial1 and they where as expected.

Then moved Tx Serial1 connector to R4 Rx Serial1 and I’m guess getting gibberish…

anyone got any ideas as to why and how to resolve please?

1 Like

just to be sure, you mean pins D0 and D1 of the R4, right?

you are aware you send binary right?

and you print it with

what do you see really in the terminal opened on the R4?

correct

yes

Its printing out random numbers (as HEX or decimal. what I posted I realise now was what I tried without the HEX printout)

Also just as a note, when performed the loopback test on the MEGA

if(Serial2.available())Serial.println(Serial2.read(),HEX);

printed out the interger value ‘i’ to serial monitor ie it was NOT interpreted a character.

Expectation is that I would see the same on the R4

1 Like

this

The gibberish happens because the UNO R4 uses 3.3V logic on Serial1 while the MEGA uses 5V. Use a level shifter or voltage divider on the MEGA’s Tx to match 3.3V, keep a common ground, and the communication will work.

could I get a second opinion on this please???

my understanding R4 IO’s are all 5V

sorry if this was confusing.

what I meant is that I also tried printing out as HEX ie I have tried:

Serial.println(Serial1.read(), HEX);

as well as

Serial.println(Serial1.read());

either case,

the output on the R4 did not match what was being tx by the MEGA and was sortof random

You are printing what read() returns which is an int so basically you should see in decimal the numbers from 0 to 11

Can you triple check the GND link ?

GND is OK.

Strangest thing ever.

tried to do a loopback on the R4 itself using softwareserial and Serial1 → that works as expected; Serial1 was reading in correctly

then moved back the MEGA and its all working NOW!!!

(could be the GND but as far as I can tell that was OK the whole time :slight_smile: )

I have also found R4 receiving alright!

glad you solved it. what you describe seems to indicate a loose wire or wrong GND