Arduino GPS Tutorial – Complete Guide

by Oscar

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

Some of the links on this page are affiliate links. I receive a commission (at no extra cost to you) if you make a purchase after clicking on one of these affiliate links. This helps support the free content for the community on this website. Please read our Affiliate Link Policy for more information.

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

Leave a Comment

By using this form, you agree with the storage and handling of your data by this website. Note that all comments are held for moderation before appearing.

13 comments

Edward Cooper 7th January 2018 - 9:13 pm

I’m looking for a solution (Arduino based) to synchronise the time on a PC Windows 10 PC with GPS time. Are you aware of a solution that has already been developed? If so do you have a link I should try for further information.

Thanks Edward

Reply
Fred Wittkampf 24th July 2015 - 10:32 am

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
truman 10th July 2015 - 7:57 pm

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
Nikos 26th November 2014 - 8:49 pm

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
John Carlo Magno 18th October 2014 - 3:45 pm

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
Oscar 20th October 2014 - 2:28 pm

okay, that’s great.

Reply
Arjun 21st January 2014 - 3:35 pm

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
Oscar 21st January 2014 - 3:46 pm

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
MIK 7th September 2013 - 9:07 pm

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
Jack 22nd July 2013 - 4:45 pm

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
Oscar 22nd July 2013 - 5:16 pm

Hi, Good Call, I thought no one would ask!
I will try to find the time to think about this…

Reply
ZH 24th October 2013 - 8:41 am

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

Reply
Abra 9th December 2013 - 12:21 pm

do you have the code to convert the gps data to google map link format?

Reply