Fetch GPS data over serial and log it to an SD card.
This uses TinyGPS to decode NMEA (RMS and GGA) sentences from a LS20031 GPS module, and then uses the the SD library to write GPX formatted data to a micro SD card.
This is a functional logger, and a good lesson about GPS modules, NMEA, and SD/FAT from Arduino. It is probably not the most efficient GPS logger (see "improvements").
Recommended configuration for the LS20031 GPS module:
// FULL COLD RESTART (clears any bad almanac data)
Serial.println("$PMTK104*37");
// GGA + RMC (all that is used by TinyGPS), 1Hz
Serial.println("$PMTK314,0,5,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0*28");
// Reduce serial output rate 57600 => 14400 baud, since SoftwareSerial
// on an 8MHz Arduino Pro Mini can't keep up (though an Uno can).
Serial.println("$PMTK251,14400*29");
Since the module sometimes loses its configuration, the Arduino startup code always sends the latter two configuration commands.
Also edit SoftwareSerial.h to have a larger buffer (default is 64):
#define _SS_MAX_RX_BUFF 256
On MacOS, it's in Arduino.app in Contents/Resources/Java/libraries/SoftwareSerial/.
Voltage and power-off detection is designed for an Arduino Pro Mini 3.3v powered from at least 3.8v (3x NiMH AAs), with a 680uF 12+v capacitor across the raw voltage supply, and a 560KOhm/120KOhm voltage divider to A3. The setup (with GPS and SD writing) draws around 42mA.
- The MTK3339 from Adafruit looks better for this application: smaller, lower power (20mA), built-in datalogging, 5v safe but accepts 3.3v power.
- Power-off detection is unreliable; a shutdown switch (perhaps a capacitive touch sensor on the casing) would be safer.
- SparkFun GPS getting-started guide
- NMEA explanations
- NMEA checksum calculator
- GPX tags specification on OpenStreetMap or Topografix
- Similar project on Arduino forums