Arduino GPS Datalogger




Introduction: Arduino GPS Datalogger

Do you want to log some GPS data onto an SD card using your Arduino? Do you already own a Sparkfun microSD shield and GPS module? Did you try the Adafruit Sheild (although it is awesome and cheap) but it stole all of your pins? Want it to output into a nice, Google Earth friendly format? Well read on...

Step 1: The Hardware

You will need:
1. An Arduino (which ever you prefer. I stick to the uno, duemilanove, mega, and this bad boy )
2. A GPS module (I'm using the EM-406 from Sparkfun )
3. A matching way to hook the GPS module to the Arduino (I went with Sparkfun's GPS Shield )
4. And a microSD Sheild (Again from Sparkfun )

Some optional stuff:
5. Indicator LED (ok ok I won't force Sparkfun on you for this guy)
6. A nice hard weatherproof case (I used the Pelican 1010 which fit perfectly)
7. Battery (No point logging GPS data tethered to your computer)

Step 2: Hook It All Up

It's a simple as, stacking the sheilds.
I put the GPS Shield on top to maximize reception.
The led is on pin 13 (see close up pic). This will flash every time it logs a GPS point.

To work with my code, make sure the little switch is set to "DLINE" on the GPS Shield. (Included a close up if you have no idea what I'm talking about) This is so we can use pins 2 and 3 to communicate with the GPS instead of the "UART" setting, which uses pins 0 and 1. This is a personal preference, modify the code as you wish. If you are using the UART, then make to switch it over to DLINE while uploading code to the Arduino if the shield is attached.

Lastly remember to have your microSD card formatted to FAT (FAT16).

Sparkfun (and many others!) has some awesome tutorials on the product pages that I referenced in this Instructable's Hardware page for both of the shields. I'd highly recommend a glance through them if this is a little too confusing. (Especially the microSD tutorial!!!!!)

Step 3: The Software

I'm assuming if you've read this far you know a bit about the Arduino and how to upload programs using the Arduino IDE, so I will not be covering the basics. Lets walk through some sudo-code

initialize serial, libraries and variables.
create a text file on SD card with header
pull GPS data
write GPS data in the end of the text file.
flash led
keep looping

I'm not going to go into my code in to much detail but it's commented enough to understand whats happening.
You will notice I'm using two really awesome libraries written by Mikal Hart, so make sure you have downloaded them! (TinyGPS and NewSoftSerial )
TinyGPS basically makes it easier for us to extract data like longitude and latitude from the slightly complex NMEA sentences that the GPS module spits out.
NewSoftSerial allows us to transform any pins into "serial pins". In this case pins 2 and 3 as previously mentioned.

The Arduino file is attached.
Just upload and it should work! (Leave a comment with the issue if it's not)

Step 4: Great We Are Logging... Now What?

So as of now, you are logging all of the gps data onto a text file named trip.txt in the root of your sd card. If you disconnect power, then reconnect, it will just append the new data to the end of that file.
You are more than welcome to write some code that reads the SD card and says: "if the file exist, make a new one with a different name." You could even get creative and use the date and time from the GPS in the filename.
The possibilities are endless. I'm just doing some basics as a proof of concept.

So it outputs a text file with a heading and the data that looks something like this:

Now you can use an awesome tool over at to create a Google Earth File with the points and their data at each.
Change the settings to your liking and use upload or copy paste.
Its as simple as that.
The picture is an output from the data above.

Step 5: The Side Note

This is my first Instructable so please play nice.
This is simply a start in the right direction for a full on data logger.
In no way did I optimize my code or hardware to be as efficient as possible.
It doesn't take things like file size or bad gps data into account.
Unplugging the power could even corrupt the SD card. Easily fixed with a button and some start-stop code.

It simply says, "if there is a gps module attached, I will log whatever it gives me"

And that's it! Feel free to ask questions and I'll do my best to answer them and have fun!!!!
Post your projects in the comments if you use this, I'd love to see what you guys are doing!

-----------------------------UPDATE 10/10/12-----------------------------
Hey guys, I'm sorry to say, this project has been discontinued for now. It has been almost a year since I published this. I haven't had much time to update and fix the bugs in the code, however it should still be compatible with older versions of the Arduino IDE and libraries. Next project that I use the sd shield for I will come back and give this another update, but for now work and school are cutting into my project time.
Thanks for your support!

Pocket-Sized Contest

Participated in the
Pocket-Sized Contest

1 Person Made This Project!


  • Make It Modular: Student Design Challenge

    Make It Modular: Student Design Challenge
  • Woodworking Contest

    Woodworking Contest
  • Science Fair Challenge

    Science Fair Challenge



5 years ago

Hi,guys ,
There is a cheap and powerful GPS expansion board here:


5 years ago

help a video


10 years ago on Introduction

nice tutorial, thanks for the code... works perfectly!


Reply 7 years ago

Where did you find the code???
Could you send it to me please? I can't find it anywhere here!


Hello I am using Jupiter 610F GPS module and there are 10 pin setup in that and the use of Vcc ground and the Output for the GPS module pin is known and what about the remaining pins and there is pin called antenna power pin should i need to give any voltage to that if so whats the value and if possible let me know with the configuration of the pin connections


8 years ago on Introduction

Can you help me with this error?

#error NewSoftSerial has been moved into the Arduino core as of version 1.0. Use SoftwareSerial instead.
In file included from GpsDataLoggerInstructable.pde:11:


Reply 7 years ago on Introduction

There was a period of time where you needed to manually install NewSoftSerial yourself, but if you keep your Arduino IDE up to date then you already have NewSoftSerial installed as SoftwareSerial. Basically they caught on that it was a better version and replaced the old one to make it the new standard Software Serial library.


7 years ago on Introduction


I'm trying to compile the code, but it does not work. I downloaded the sdfat and TinyGPS to the library.

In file included from sketch_aug27a.ino:15:

C:\Users\Y510P\Documents\Arduino\libraries\SdFat2/SdFat.h:294: error: conflicting return type specified for 'virtual void SdFile::write(uint8_t)'

D:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Print.h:48: error: overriding 'virtual size_t Print::write(uint8_t)'

adham rabea
adham rabea

9 years ago on Step 3

can u upload the full software plz


Reply 9 years ago on Introduction

Not sure what you mean by "full software" but I just zipped the file to fix that download issue that people have been having. I added an update to the end of the Instructable too.


9 years ago on Introduction

Hi Jonny,

I am using your code but it is not printing any values to sd card. Do you know what might be the issue? it creates the text file and adds in "year,month,day,hour,minute,seconds,latitude,longitude,altitude(ft),speed(mph),course" but it does not actually print any values from the gps. The text file is blank besides that one line.


Reply 9 years ago on Introduction

Hmmm I am not to sure. The bulk of the problems usually come from actually writing to the card. Try printing some of the gps values to the serial port and see if you can see them. If you can then I would say the issue lies in the code where it is compiling that string of all the values. I will admit that this code is very old and probably not compatible with Arduino 1.0. I already owe Rustie0125 some new code from almost 4 months ago now... I can see what I can do and try to release version 2.0