gps-serial1.ino
The Due lines up four hardware UARTs: Serial1 (pins 19/18) stays free while USB serves debugging. The filter keeps only the NMEA GGA sentence, the most useful (time, latitude, longitude).
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 TTL GPS module (GP-20U7, NEO-6M) at 3.3 V or 5 V per model.
Wiring
GPS TX → RX1 (pin 18), common ground; module powered at 3.3/5 V.
How it works
Characters accumulate until the line feed; $GPGGA sentences are truncated and printed on the USB monitor. In the Arduino IDE, select « Arduino Due (Programming Port) » then Upload; the serial monitor runs at the speed set in the code.
Going further
Also parse $GPRMC (speed, course) or push the position to a server through an Ethernet module.
gps-serial1.ino
// GPS 9600 bauds sur Serial1 (TX1=19, RX1=18), extraction du $GPGGA.
void setup() {
Serial.begin(9600); // USB debug
Serial1.begin(9600); // USART1: broches 19 (TX1) / 18 (RX1)
Serial.println(F("En attente de trames GPS..."));
}
void loop() {
static String ligne = "";
while (Serial1.available()) {
char c = Serial1.read();
if (c == '\r') continue;
if (c == '\n') {
if (ligne.startsWith("$GPGGA")) {
// $GPGGA,heure,lat,N,lon,E,...
Serial.println(ligne.substring(0, 40));
}
ligne = "";
} else ligne += c;
}
}