pont-usb-serial1.ino

Arduino Due · File : pont-usb-serial1.ino · Language : Arduino · Use case : Relayer l'UART1 vers le port USB pour debugger un module série

Before writing a driver you must see what the module says: this bridge copies everything between UART1 and USB, both ways — so you can also type AT commands. The classic GSM/GPS bring-up tool.

Hardware required

An Arduino Due (AT91SAM3X8E, ARM Cortex-M3 at 84 MHz) connected over USB to its « Programming » port. Caution: 3.3 V logic, never 5 V on the pins. 1 3.3 V serial module (GPS, SIM800/900 at matching level).

Wiring

Module TX → 18 (RX1), module RX → 19 (TX1), common grounds; power the module separately if it spikes.

How it works

Two while loops copy bytes each way; no software buffer needed thanks to the UART FIFO. In the Arduino IDE, select « Arduino Due (Programming Port) » then Upload; the serial monitor runs at the speed set in the code.

Going further

Add a baud-rate switch (76800 for SIM800) or filter prefixes to show only useful sentences.

pont-usb-serial1.ino

// Pont Serial1 (GPS, GSM...) <-> USB : ce que dit le module s'affiche.
void setup() {
  Serial.begin(9600);  // port USB (Programming ou Native)
  Serial1.begin(9600); // broches 19/18
  Serial.println(F("Pont Serial1 <-> USB (9600)"));
}

void loop() {
  while (Serial1.available()) {
    Serial.write(Serial1.read()); // module -> moniteur
  }
  while (Serial.available()) {
    Serial1.write(Serial.read()); // clavier -> module (commandes AT)
  }
}

← Back to the board