Arduino GPS Tutorial – Complete Guide

Do I need to say more about GPS? See here for some background info: Global Positioning System (GPS)

In this tutorial, I will be showing you how to use Arduino, a GPS Arduino shield and a SD card to make a handheld Arduino GPS logger, to record your latitude and longitude over the course of a day.

Addition to this tutorial, check out my latest post about how to use the GPS with Arduino.

I will be taking it step by step:

  1. How does it work?
  2. How to interface this into your robot or other projects

Basic GPS Working Concept

GPS satellites orbit the Earth at an approximate altitude of 20,000 km. For a GPS unit to fix its location it needs to receive signal from at least 3 satellites.

The GPS signal that is transmitted from each satellite contains:

  • Time (accuracy of millisecond) (GMT time).
  • Date
  • Position (accuracy of 2 to 3 meters)
  • Altitude

From these information, it is also possible to work out compass heading and speed.

The Tools

The reason we use Arduino is because it’s very easy to integrate into different projects, and it’s very popular among electronics hobbyists. I also will be paring the Arduino with a GPS Shield which uses a USGlobalSat EM-406A receiver.

Arduino GPS Tutorial

Arduino GPS Work Through

Okay, let’s get our hands dirty. I will break the tutorial into 3 parts.

Part One: Receiving Data from the GPS Unit via Serial Port

Firstly, we set up the system in basic configuration. We will try to talk directly to the GPS via its serial port just by connecting a FTDI cable direct to the GPS shield board, so we can check what kind of data we will be receiving on our computer.

  • Remove the ATmega chip on the Arduino Board as we only need the serial circuit on the Arduino.
  • Place a jumper cable between digital i/o pin 2 and ground (as Shown Below).
  • This switches the GPS Unit on and you can use the Arduino’s serial port to read the data.
  • Then wire the GPS unit so that:

GPS RX to digital pin 0
GPS TX to digital pin 1
GPS PWR to digital pin 2

Arduino GPS Tutorial

The GPS unit can be attached to the Arduino and the USB connected.

Select the Arduino’s Serial Port and adjust the speed to 4800 Baud.

The resulting output stream should look something similar to this:

$GPRMC,150135.000,A,4725.0890,N,00922.8760,E,0.06,198.98,190309,,*00
$GPGGA,150136.000,4725.0890,N,00922.8758,E,1,04,3.0,766.6,M,48.0,M,,0000*58
$GPGSA,A,3,13,25,23,20,,,,,,,,,3.2,3.0,1.0*37
$GPRMC,150136.000,A,4725.0890,N,00922.8758,E,0.05,195.81,190309,,*0E
$GPGGA,150137.000,4725.0891,N,00922.8757,E,1,04,3.0,766.4,M,48.0,M,,0000*55
$GPGSA,A,3,13,25,23,20,,,,,,,,,3.2,3.0,1.0*37
$GPRMC,150137.000,A,4725.0891,N,00922.8757,E,0.07,208.54,190309,,*0C
$GPGGA,150138.000,4725.0892,N,00922.8755,E,1,04,3.0,766.3,M,48.0,M,,0000*5C
$GPGSA,A,3,13,25,23,20,,,,,,,,,3.2,3.0,1.0*37
$GPRMC,150138.000,A,4725.0892,N,00922.8755,E,0.04,197.77,190309,,*05
$GPGGA,150139.000,4725.0892,N,00922.8755,E,1,04,3.0,766.2,M,48.0,M,,0000*5C
$GPGSA,A,3,13,25,23,20,,,,,,,,,3.2,3.0,1.0*37
$GPRMC,150139.000,A,4725.0892,N,00922.8755,E,0.05,178.49,190309,,*09

Lets break it down the last Bold Line

  • $GP —– Geographic Position
  • RM ——- Reccomended Minimum
  • 150139.000 ——– Time 15:01 and remainder in milliseconds
  • A ——— Active (else could be V for Void)
  • 4725.0892,N —— Position Latitude 47 Deg 25.0892 Minutes North
  • 00922.8755,E ——Position Longitude 009 Deg 22.8755 Minutes East
  • 190309 ——— Date 19th march 2009
  • *09 —— Checksum
  • $GPGSA string contain information about quality of signal
  • $GPGGA string contains location – quality of signal – and amazingly Altitute information

Part Two: Process GPS Data In Arduino

Remove the Jumper off the Arduino and Plug the ATMEGA chip back in and install the GPStest_RMC.pde script. Don’t forget to install a AFSoftSerial.h library into the Hardware/Libraries

Then wire the Arduino GPS unit (picture above) :

GPS RX to digital pin 3
GPS TX to digital pin 2
GPS PWR to digital 4

Open up the Arduino’s Serial Port and set to 4800 Baud

The resulting output stream looks a bit like this:

read:
$GPGGA,152635.000,4725.0900,N,00922.9192,E,1,05,3.9,809.1,M,48.0,M,,0000*5E
read:
$GPGSA,A,3,13,23,16,25,07,,,,,,,,5.1,3.9,3.4*3F
read:
$GPGSV,3,1,11,07,69,140,36,25,65,075,43,13,54,059,44,02,42,264,*79
read:
$GPGSV,3,2,11,23,24,073,46,16,10,034,30,20,01,128,,08,38,193,21*78
read:
$GPGSV,3,3,11,04,34,211,28,10,22,304,15,29,01,332,*48
read:
$GPRMC,152635.000,A,4725.0900,N,00922.9192,E,0.21,257.90,190309,,*0A
Time: 15:26:35
Date: 3/19/9
Lat: +470 25' 5.40"
Long: +90 22' 55.15"

If you notice the Arduino GPS has extracted the data (in Bold) into variables which can be used in your normal programming.

As simple as that.

Part 3: Use 3rd Party Software to Display the Arduino GPS Data

With the Arduino Set up this way you can attach many third party GPS software packages.
Here is a free-ware version called mini GPS.

Arduino GPS Tutorial

If you take a close look the Altitude – Speed – and Track (heading) are also calculated.

Arduino GPS Tutorial

12 thoughts on “Arduino GPS Tutorial – Complete Guide

  1. Fred Wittkampf

    Hi Oscar
    I am totally new in this field, newbee.
    For my metal boat I want to make a compass that is only based on GPS data. So non-magnetic.
    Simple, but not commercially available.
    Display only needs to show heading (degrees).
    Sounds like possible with arduino of raspberry.
    Any advice ? or do you know someone who can built this for me?

    Reply
  2. truman

    Hi Oscar

    I”ll to know is it possible to repalce “USGlobalSat EM-406A ” with “Skylab Skynav SKM53 GPS w/ MT3329”?
    What is the disadvantage of this replacement?

    Reply
  3. Nikos

    Good job, the tutorial looks simple and nice. Two questions:

    1. Can I use this setup to get the approximate speed of a vehicle?

    2. Does the GPS receiver need to have a SIM card to work?

    Reply
  4. John Carlo Magno

    Hello there. We are having a research right now which includes GPS tracking capabilities, we want to include in our project that the data from the gps device would directly give the information of the location not just like latitude and longitude, maybe it can directly indicate the place or address

    Reply
  5. Arjun

    Hello
    I am a newbee in this field. Can you please tell me if it is essential to use gps shield, or is it okay if we directly interface gps module with the arduino.
    Thank you.

    Reply
    1. Oscar

      Hi, yes you can connect the GPS to the Arduino directly. The shield here has a SD card slot for saving data, that’s the reason for it.

      As a matter of fact, I am starting a new GPS project in a week or two, stay tuned if you are interested in that kind of stuff :-D

      Reply
  6. MIK

    hello
    I am a newbee in arduino ( not in electronics)
    I am trying to make an adruino gps system (for planes ) that would allow to store several coordinate points
    ( off line) and in flight retrieve one of them ( via an arduino menu) and then navigate to this point displaying heading and time according to speed.
    what would be your suggestion
    many thanks
    mik

    Reply
  7. Jack

    Hello
    Can you please make a code to convert gps data to a google map link in real time , because i want to send it as SMS for tracking issue , it will be nice to make this code .
    Thanks

    Reply
      1. ZH

        Hi, did you managed to create a code to covert gps data into google map? i am doing the same project too:/

Leave a Reply

Your email address will not be published. Required fields are marked *

Are you Robot? *

I don't look at blog comments very often (maybe once or twice a week), so if you have any questions related to multirotor please post it on this forum IntoFPV.com... You're likely to get a response from me faster on there.