🛠 Deux ports série : Serial (USB) et Serial1 (broches 0/1)

Arduino Nano Every · intermediaire · Schéma : IMG-nano-every-intermediaire-3-nanoevery-serial1-vs-serial.svg — Nano Every au centre avec d'un côté le câble USB reliant la carte au PC (port Serial) et de l'autre un module GPS branché sur les broches 0 et 1 (port Serial1), flèches de données dans les deux sens

Objectives

Take advantage of one of the major benefits of the Nano Every over the classic Nano: two hardware UARTs accessible on the connector. Serial goes through the USB bridge module (PC monitor), while Serial1 corresponds to the ATmega4809's USART on pins 0 (RX) and 1 (TX) in TTL. We build a pass-through: everything arriving from one side is output on the other.

Hardware

Complete code

// Passe-plat USB <-> UART broches 0(RX)/1(TX)
// Garde le moniteur USB libre pour le debogage pendant qu'un
// module (GPS, BLE...) parle sur Serial1.
void setup {
  Serial.begin(115200);    // USB (module pont embarque)
  Serial1.begin(9600);     // USART materielle sur broches 0/1
  Serial.println(F("Passe-plat pret: PC <-> module"));
}

void loop {
  if (Serial.available)  Serial1.write(Serial.read);    // PC -> module
  if (Serial1.available) Serial.write(Serial1.read);    // module -> PC
}

Expected verification

Connect the module to 0/1 (module RX → pin 1, module TX → pin 0, powered at 5 V or 3.3 V depending on the module). Open the serial monitor at 115200: you see the module's frames scrolling by; what you type from the PC is sent to the module. The USB port remains usable for debugging in parallel — impossible on the classic Nano, which has only one UART.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials