multi-serie.ino

Arduino Nano Every · File : multi-serie.ino · Language : Arduino · Use case : Exploiter les 4 ports série du 4809

The Nano Every big win over the classic: four hardware UARTs. This bridge copies Serial1 (pins D0/D1) to the USB port, handy to listen to a GPS or voice module while keeping the serial monitor free for debugging.

Hardware

An Arduino Nano Every (ATmega4809 at 20 MHz, same footprint as the Nano, micro-B USB, separate UART chip, 5 V pins, drop-in compatibility with the classic Nano). Nano Every, 3.3/5 V serial device on D0/D1 (GPS, serial sensor), USB cable.

Wiring

Module TX→D0 (board RX), module RX→D1, common ground; the 4809 is 5 V logic, 3.3 V tolerant.

How it works

Each SerialX drives a real transceiver of the 4809: no bit-banging. Non-blocking available/read loops bridge both directions at 9600 baud.

Running it

Install the Arduino megaAVR Boards package in the IDE, select Arduino Nano Every, upload. The USB Serial is separate from hardware Serial1 (RX/TX pins): classic serial code works as is.

Variants

Assign Serial2/Serial3 (E1RX/E1TX pins) to a second device for a 3-way hub, or raise the rate for a serial WiFi module.

multi-serie.ino

// Le Nano Every (ATmega4809) possede 4 Uarts materiels.
// Serial = USB (vers le PC), Serial1 = broches D0/D1, etc.
void setup() {
  Serial.begin(9600);    // pont USB du board
  Serial1.begin(9600);   // D0=RX D1=TX : GPS, module voix...
  Serial2.begin(9600);   // broches dediees (voir schema) : E1RX/E1TX
  Serial.println(F("Serial  USB pret"));
  Serial1.println(F("Hello sur D0/D1"));
}

void loop() {
  // Pont serie : ce qui arrive sur Serial1 part sur l'USB
  while (Serial1.available()) {
    char c = Serial1.read();
    Serial.write(c);
    // boucle de dialogue simple sur l'uart annexe
    if (c == 'H') Serial1.println(F("OK depuis le Nano Every"));
  }
  // Et inversement : les commandes tapees sur l'USB partent sur D0/D1
  while (Serial.available()) {
    Serial1.write(Serial.read());
  }
}

← Back to the board