Arduino Nano EVERY access to 4 Serial

So according to the datasheet (http://ww1.microchip.com/downloads/en/DeviceDoc/48-pin-Data-Sheet-megaAVR-0-series-DS40002016B.pdf) the arduino Nano EVERY processor should have 4 USART (i.e. Serial).

From the documentation it seems that only Serial (via USB) and Serial1 (Pin TX1 RX0) are supported, but the other serial pins are connected to the jumpers (PA0 and PA1 are in D2 and D7, PF4 PF5 are in D6 D3).

Is there some documentation on how to enable the other 2 serials on the digital pins? Do we have to work on registers?

You can enable the serial ports by modifying the #define statements for HWSERIAL2 and HWSERIAL3 in the pins_arduino.h file, the code for the additional ports is already present. Played around with it a bit, seems to work OK when sending/receiving to external devices, was having some problems when sending between ports on the same nano every board, if I recall correctly I could not get all four ports sending/receiving simultaneously under those conditions, not sure of the exact problem but was speculating the simultaneous interrupts on multiple ports may have been the cause.

Had to do a bit of searching to find where I had worked on it before, part of it got lost with an update in the IDE boards manager.

In the .arduino15/packages/arduino/hardware/megaavr/1.8.5/variants/nona4809/pins_arduino.h file I changed the lines:

#define HWSERIAL2_MUX (PORTMUX_USART0_NONE_gc)
#define HWSERIAL3_MUX (PORTMUX_USART2_NONE_gc)

to the following:

//#define HWSERIAL2_MUX (PORTMUX_USART0_NONE_gc)
// Serial2 USART available on Arduino header pins
// USART0 on mega4809 (standard pins)
// Mapped to HWSERIAL2 in Serial library
#define HWSERIAL2 (&USART0)
#define HWSERIAL2_DRE_VECTOR (USART0_DRE_vect)
#define HWSERIAL2_DRE_VECTOR_NUM (USART0_DRE_vect_num)
#define HWSERIAL2_RXC_VECTOR (USART0_RXC_vect)
#define HWSERIAL2_MUX (PORTMUX_USART0_DEFAULT_gc)
#define PIN_WIRE_HWSERIAL2_RX (7)
#define PIN_WIRE_HWSERIAL2_TX (2)

//#define HWSERIAL3_MUX (PORTMUX_USART2_NONE_gc)
// Serial3 USART available on Arduino header pins
// USART2 on mega4809 (alternate pins)
// Mapped to HWSERIAL3 in Serial library
#define HWSERIAL3 (&USART2)
#define HWSERIAL3_DRE_VECTOR (USART2_DRE_vect)
#define HWSERIAL3_DRE_VECTOR_NUM (USART2_DRE_vect_num)
#define HWSERIAL3_RXC_VECTOR (USART2_RXC_vect)
#define HWSERIAL3_MUX (PORTMUX_USART2_ALT1_gc)
#define PIN_WIRE_HWSERIAL3_RX (3)
#define PIN_WIRE_HWSERIAL3_TX (6)

Also altered the code at the end of the same file:

#define SERIAL_PORT_MONITOR       Serial
#define SERIAL_PORT_HARDWARE      Serial1
#define SERIAL_PORT_USBVIRTUAL    Serial

to this - not sure if it is correct, was using the code for a mega board as an example.

#define SERIAL_PORT_MONITOR       Serial
#define SERIAL_PORT_HARDWARE      Serial1
#define SERIAL_PORT_HARDWARE1     Serial2
#define SERIAL_PORT_HARDWARE2     Serial3
#define SERIAL_PORT_USBVIRTUAL    Serial
#define SERIAL_PORT_HARDWARE_OPEN   Serial1
#define SERIAL_PORT_HARDWARE_OPEN1  Serial2
#define SERIAL_PORT_HARDWARE_OPEN2  Serial3

After those changes the ports will be usable as:

Serial2:
Rx on D7
Tx on D2

Serial3:
Rx on D3
Tx on D6

Almost posted this in the past to ask if anyone would be interested in doing some testing to see if it would work properly, but never got around to it.

That't great, thanks.

Hello. Noob here. How do I know which pins_arduino.h my sketch is using? I selected Nano Every board and native register namings. Also where I can find arduino15/packages/arduino/hardware/megaavr/1.8.5/variants/nona4809/pins_arduino.h? I don't see the folder arduino15.

NVM. I've found it. So I assumed if I made the changes per post #2, then Serial2 and Serial3 will work even when transferring data between ports?

:o

I have been looking but still cannot find this file, have they changed the directory structure?
Really could use another hardware UART on the EVERY

I cannot find the NONA4809 file?

Also can they start naming the Nanos like play station with numbers. Every is the worst searchable.

@potatofarmer You need to install megaAVR in the boards manager (On a mac anyway)

Much easier now to use MCUdude's MegaCoreX, that supports the serial ports without having to modify any files.