For Arduino UNO and other Atmega 328 boards: Due to limited memory, the shield_sdlog example will not work with the latest version of the library. If you want to log GPS messages on the UNO, you will need to install version 1.3 or earlier of the GPS library.
Finally we get to the fun stuff! Its time to log data from the GPS onto an SD card. First up we'll do a basic test to make sure the SD card system is working.

You'll need a microSD card to log data onto. Any capacity will do. Slide the microSD card into the silver socket. You can push it in and you'll feel it latch and click

To remove, push on the edge and it will pop out (be careful it doesn't fly across the room!)

SD Card Library Update

If you are using an Leonardo or Mega, you will have to update the SD card library to add 'SD card on any pin' support. If you have an Uno/Duemilanove/Diecimila, this is not required.

First, find the "core libraries" folder - if you are using Windows or Linux, it will be in the folder that contains the Arduino executable, look for a libraries folder. Inside you will see an SD folder (inside that will be SD.cpp SD.h etc)

In the libraries folder, make a new folder called SDbackup. Then drag the SD folder into SDbackup, this will 'hide' the old SD library without deleting it
Now we'll grab the new SD library, visit and click the ZIP download button, or click the button below

Uncompress and rename the uncompressed folder SD. Check that the SD folder contains SD.cpp and SD.h

Place the SD library folder your sketchbook libraries folder. You may need to create the libraries subfolder if its your first library. For more details on how to install libraries, check out our ultra-detailed tutorial at

Once installed, restart the IDE. Then open up the Adafruit_GPS->shield_sdlog sketch and upload it to your Arduino.

If you're using a Leonardo, uncomment the line
// while (!Serial);
in the top of the Setup() function - this will help make debugging easier.

If you are using an Uno/Duemilanove/Diecimila or compatible, Find these two lines
if (!SD.begin(chipSelect, 11, 12, 13)) {
//if (!SD.begin(chipSelect)) { // if you're using an UNO, you can use this line instead
And comment out the first one and uncomment the second one.

Make sure you have the switch set to Soft Serial and open up the serial monitor and check that you're connected at 115200 baud (or you'll get gibberish)

If the SD card was initialized OK, it will read a sentence from the GPS, check the checksum and if its a proper sentence, and then log it.

You can customize this basic example by changing the sendCommand in the top of setup(), for example you can turn on different sentences (although RMC and GGA are the most desirable, we've found). Or change the update rate to 5Hz instead of 1Hz

You can also set it so only 'fixed' data is logged - that is, there has to be valid location data. Doing so reduces power usage and saves space but its harder to debug because you don't get the timestamps that are in the RMC sentences.

This guide was first published on Feb 18, 2013. It was last updated on Jul 13, 2021.

This page (SD Logging) was last updated on Feb 18, 2013.

Text editor powered by tinymce.