Library Issue with the R4 (serial1.begin)

Just thought i would throw this in, porting some code from my mega2560 codebase to the R4 and its using Serial1, and i didn['t even think of it.

It compiles fine, but obviously doesn't work because Serial1 doesn't exist, but it doesn't look like the board basecode doesn't warn on Serial1 and above not existing.

Hi @rainwulf. Serial1 does exist so it is expected that it will compile without any warning or error.

As documented here:

https://docs.arduino.cc/tutorials/uno-r4-minima/cheat-sheet#usb-serial--uart

One of the differences between the UNO R3 and R4 is that the R4 has a dedicated hardware serial port on pins 0 and 1 (whereas the R3 has a single port connected both to the USB bridge and to those pins). This is why the hardware serial port object for pins 0 and 1 is named Serial1 instead of Serial on the UNO R4.

Oh wow thank you. So serial1 will actually punch data out to pins 0 and 1, where as "Serial" will go over the USB.

That actually makes me very happy. Thank you!

1 Like

You are welcome. I'm glad if I was able to be of assistance.

Regards,
Per

1 Like