Home > Ideas > GPS Based Project Ideas > Arduino GPS Datalogger

Arduino GPS Datalogger

Summary of Arduino GPS Datalogger


This article guides users on building an Arduino GPS datalogger that records location data to an SD card in a Google Earth-friendly format. It details the hardware stacking process, specifically configuring the GPS shield to use pins 2 and 3 via the DLINE switch, and formatting the SD card to FAT16. The software section highlights the use of TinyGPS and NewSoftSerial libraries within the Arduino IDE to extract and write NMEA sentences to a text file while flashing an LED indicator.

Parts used in the Arduino GPS Datalogger:

  • Arduino (Uno, Duemilanove, or Mega)
  • EM-406 GPS module
  • Sparkfun GPS Shield
  • Sparkfun microSD Shield
  • Indicator LED
  • Pelican 1010 weatherproof case
  • Battery

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 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).

Arduino GPS Datalogger

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.

Major Components in Project

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)

For more detail: Arduino GPS Datalogger

Quick Solutions to Questions related to Arduino GPS Datalogger:

  • How do I configure the GPS shield for communication?
    Set the little switch on the GPS Shield to "DLINE" to use pins 2 and 3 instead of UART.
  • What file system is required for the microSD card?
    The microSD card must be formatted to FAT (FAT16).
  • Which libraries are needed for this project?
    You need the TinyGPS and NewSoftSerial libraries written by Mikal Hart.
  • Can I use other Arduino boards besides the Uno?
    Yes, you can use the Uno, Duemilanove, Mega, or any other preferred Arduino model.
  • What does the LED on pin 13 indicate?
    The LED flashes every time the system logs a new GPS point.
  • Why should I set the switch to DLINE during code upload?
    If using UART, you must switch to DLINE while uploading code if the shield is attached to avoid pin conflicts.
  • What format does the output data support?
    The system outputs data in a nice, Google Earth friendly format.
  • Is it necessary to tether the device to a computer?
    No, a battery is recommended so you can log GPS data without being tethered.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter
Scroll to Top