Play Arduino With Global Positioning System (GPS)

We have a Arduino GPS shield for Arduino,it is a compact, high performance, and low power consumption GPS engine board. It uses SiRF Star III chipset which can track up to 20 satellites at a time and perform fast TTFF in weak signal environments. It’s suitable for the following applications with Arduino or Arduino compatible boards :

  • Automotive navigation
  • personal positioning
  • fleet management
  • marine navigation

Here is a small demo that show you how to read and log the GPS data into a SD card. Because this Arduino GPS shield has a Micro SD card socket, so we don’t need to use the external shield or module/brick, just plug it on the Arduino or Iteduino.

Upload the demo code here into the the Arduino, and the Arduino will read out the information of GPS and write it into the Micro SD card. Before this, you should make sure the Micro SD card you use is support SPI mode but not just the SD mode, also don’t forget to format it into FAT16 , and add a “datalog.txt” file on your card for Arduino to log the information.

You can see the data in the datalog.txt like this:

$PSRFTXT,Version:GSW3.2.4_3.1.00.12-SDK003P1.00a 
$PSRFTXT,Version2:F-GPS-03-0701231
$PSRFTXT,WAAS Disable
$PSRFTXT,TOW:  105921
$PSRFTXT,WK:   1538
$PSRFTXT,POS:  -2170399 4386065 4076920
$PSRFTXT,CLK:  95585
$PSRFTXT,CHNL: 12
$PSRFTXT,Baud rate: 4800 
$GPGGA,052613.172,3959.1983,N,11619.6639,E,0,03,,74.0,M,-6.5,M,,0000*5B
$GPGSA,A,1,30,14,29,,,,,,,,,,,,*13
$GPRMC,052613.172,A,3959.1983,N,11619.6639,E,,,290609,,*01
$GPGGA,052614.266,3959.2084,N,11619.6691,E,1,03,4.1,74.0,M,-6.5,M,,0000*7F
$GPGSA,A,2,30,14,29,,,,,,,,,,4.2,4.1,1.0*3C
$GPRMC,052614.266,A,3959.2084,N,11619.6691,E,1.24,10.61,290609,,*3E
$GPGGA,052615.269,3959.2074,N,11619.6690,E,1,03,4.1,74.0,M,-6.5,M,,0000*7F
$GPGSA,A,2,30,14,29,,,,,,,,,,4.2,4.1,1.0*3C
$GPRMC,052615.269,A,3959.2074,N,11619.6690,E,2.09,90.96,290609,,*32
$GPGGA,052616.269,3959.2080,N,11619.6676,E,1,04,3.9,48.4,M,-6.5,M,,0000*7C
$GPGSA,A,3,30,14,29,12,,,,,,,,,4.0,3.9,1.0*33
$GPRMC,052616.269,A,3959.2080,N,11619.6676,E,0.39,281.94,290609,,*03
$GPGGA,052617.266,3959.2117,N,11619.6940,E,1,04,6.9,70.3,M,-6.5,M,,0000*7E
$GPGSA,A,3,30,14,29,12,,,,,,,,,8.3,6.9,4.5*39
$GPGSV,3,1,10,14,56,115,34,30,37,049,41,29,23,103,34,12,08,041,30*73
$GPGSV,3,2,10,16,75,122,,21,51,183,,31,50,055,,20,23,309,*7E
$GPGSV,3,3,10,22,21,297,,18,03,169,*73
$GPRMC,052617.266,A,3959.2117,N,11619.6940,E,0.10,299.68,290609,,*09
$GPGGA,052618.000,3959.2142,N,11619.7011,E,1,04,6.9,80.7,M,-6.5,M,,0000*74
$GPGSA,A,3,30,14,29,12,,,,,,,,,8.3,6.9,4.5*39
$GPRMC,052618.000,A,3959.2142,N,11619.7011,E,0.16,318.14,290609,,*0D
$GPGGA,052619.000,3959.2174,N,11619.7146,E,1,04,6.9,90.3,M,-6.5,M,,0000*76
 
These are GPS sentences, these sentences includes the position, time, speed, altitude information and so on. Below is all sentence codes and short descriptions:
  • $GPAAM – Waypoint Arrival Alarm
  • $GPALM – GPS Almanac Data
  • $GPAPA – Autopilot format “A”
  • $GPAPB – Autopilot format “B”
  • $GPASD – Autopilot System Data
  • $GPBEC – Bearing & Distance to Waypoint, Dead Reckoning
  • $GPBOD – Bearing, Origin to Destination
  • $GPBWC – Bearing & Distance to Waypoint, Great Circle
  • $GPBWR – Bearing & Distance to Waypoint, Rhumb Line
  • $GPBWW – Bearing, Waypoint to Waypoint
  • $GPDBT – Depth Below Transducer
  • $GPDCN – Decca Position
  • $GPDPT – Depth
  • $GPFSI – Frequency Set Information
  • $GPGGA – Global Positioning System Fix Data
  • $GPGLC – Geographic Position, Loran-C
  • $GPGLL – Geographic Position, Latitude/Longitude
  • $GPGRS – GPS Range Residuals
  • $GPGSA – GPS DOP and Active Satellites
  • $GPGST – GPS Pseudorange Noise Statistics
  • $GPGSV – GPS Satellites in View
  • $GPGXA – TRANSIT Position
  • $GPHDG – Heading, Deviation & Variation
  • $GPHDT – Heading, True
  • $GPHSC – Heading Steering Command
  • $GPLCD – Loran-C Signal Data
  • $GPMSK – Control for a Beacon Receiver
  • $GPMSS – Beacon Receiver Status
  • $GPMTA – Air Temperature (to be phased out)
  • $GPMTW – Water Temperature
  • $GPMWD – Wind Direction
  • $GPMWV – Wind Speed and Angle
  • $GPOLN – Omega Lane Numbers
  • $GPOSD – Own Ship Data
  • $GPR00 – Waypoint active route (not standard)
  • $GPRMA – Recommended Minimum Specific Loran-C Data$GPRMB – Recommended Minimum Navigation Information
  • $GPRMC – Recommended Minimum Specific GPS/TRANSIT Data
  • $GPROT – Rate of Turn
  • $GPRPM – Revolutions
  • $GPRSA – Rudder Sensor Angle
  • $GPRSD – RADAR System Data
  • $GPRTE – Routes
  • $GPSFI – Scanning Frequency Information
  • $GPSTN – Multiple Data ID
  • $GPTRF – TRANSIT Fix Data
  • $GPTTM – Tracked Target Message
  • $GPVBW – Dual Ground/Water Speed
  • $GPVDR – Set and Drift
  • $GPVHW – Water Speed and Heading
  • $GPVLW – Distance Traveled through the Water
  • $GPVPW – Speed, Measured Parallel to Wind
  • $GPVTG – Track Made Good and Ground Speed
  • $GPWCV – Waypoint Closure Velocity
  • $GPWNC – Distance, Waypoint to Waypoint
  • $GPWPL – Waypoint Location
  • $GPXDR – Transducer Measurements
  • $GPXTE – Cross-Track Error, Measured
  • $GPXTR – Cross-Track Error, Dead Reckoning
  • $GPZDA – UTC Date / Time and Local Time Zone Offset
  • $GPZFO – UTC & Time from Origin Waypoint
  • $GPZTG – UTC & Time to Destination Waypoint

Many of the sentences is not used, only a few need to have practical value. So here we only to explain some of the frequently used commands:

$GPGGA: Global Positioning System Fix Data

eg1. $GPGGA,170834,4124.8963,N,08151.6838,W,1,05,1.5,280.2,M,-34.0,M,,,*59

Name Example Data Description
Time 170834 17:08:34 UTC
Latitude 4124.8963, N 41d 24.8963′ N or 41d 24′ 54″ N
Longitude 08151.6838, W 81d 51.6838′ W or 81d 51′ 41″ W
Fix Quality:
– 0 = Invalid
– 1 = GPS fix
– 2 = DGPS fix
1 Data is from a GPS fix
Number of Satellites 05 5 Satellites are in view
Horizontal Dilution of Precision (HDOP) 1.5 Relative accuracy of horizontal position
Altitude 280.2, M 280.2 meters above mean sea level
Height of geoid above WGS84 ellipsoid -34.0, M -34.0 meters
Time since last DGPS update blank No last update
DGPS reference station id blank  No station id
Checksum *75 Used by program to check for transmission errors

Courtesy of Brian McClure, N8PQI.

Global Positioning System Fix Data. Time, position and fix related data for a GPS receiver.

eg2. $GPGGA,hhmmss.ss,ddmm.mmm,a,dddmm.mmm,b,q,xx,p.p,a.b,M,c.d,M,x.x,nnnn

hhmmss.ss = UTC of position 
ddmm.mmm = latitude of position
a = N or S, latitutde hemisphere
dddmm.mmm = longitude of position
b = E or W, longitude hemisphere 
q = GPS Quality indicator (0=No fix, 1=Non-differential GPS fix, 2=Differential GPS fix, 6=Estimated fix) 
xx = number of satellites in use 
p.p = horizontal dilution of precision 
a.b = Antenna altitude above mean-sea-level
M = units of antenna altitude, meters 
c.d = Geoidal height
M = units of geoidal height, meters 
x.x = Age of Differential GPS data (seconds since last valid RTCM transmission) 
nnnn = Differential reference station ID, 0000 to 1023

$GPSSV: GPS Satellites in view

eg. $GPGSV,3,1,11,03,03,111,00,04,15,270,00,06,01,010,00,13,06,292,00*74
    $GPGSV,3,2,11,14,25,170,00,16,57,208,39,18,67,296,40,19,40,246,00*74
    $GPGSV,3,3,11,22,42,067,42,24,14,311,43,27,05,244,00,,,,*4D
 
1    = Total number of messages of this type in this cycle
2    = Message number
3    = Total number of SVs in view
4    = SV PRN number
5    = Elevation in degrees, 90 maximum
6    = Azimuth, degrees from true north, 000 to 359
7    = SNR, 00-99 dB (null when not tracking)
8-11 = Information about second SV, same as field 4-7
12-15= Information about third SV, same as field 4-7
16-19= Information about fourth SV, same as field 4-7

$GPGSA: GPS DOP and active satellites

eg1. $GPGSA,A,3,,,,,,16,18,,22,24,,,3.6,2.1,2.2*3C
eg2. $GPGSA,A,3,19,28,14,18,27,22,31,39,,,,,1.7,1.0,1.3*34
 
1    = Mode:
       M=Manual, forced to operate in 2D or 3D
       A=Automatic, 3D/2D
2    = Mode:
       1=Fix not available
       2=2D
       3=3D
3-14 = PRN’s of Satellite Vechicles (SV’s) used in position fix (null for unused fields)
15   = Position Dilution of Precision (PDOP)
16   = Horizontal Dilution of Precision (HDOP)
17   = Vertical Dilution of Precision (VDOP)

$GPRMC: Recommended minimum specific GPS/TRANSIT data

eg1.  $GPRMC,225446,A,4916.45,N,12311.12,W,000.5,054.7,191194,020.3,E*68

            225446       Time of fix 22:54:46 UTC
           A            Navigation receiver warning A = Valid position, V = Warning
           4916.45,N    Latitude 49 deg. 16.45 min. North
           12311.12,W   Longitude 123 deg. 11.12 min. West
           000.5        Speed over ground, Knots
           054.7        Course Made Good, degrees true
           191194       UTC Date of fix, 19 November 1994
           020.3,E      Magnetic variation, 20.3 deg. East
           *68          mandatory checksum
 
eg2. $GPRMC,220516,A,5133.82,N,00042.24,W,173.8,231.8,130694,004.2,W*70
            1   220516     Time Stamp
             2   A          validity – A-ok, V-invalid
             3   5133.82    current Latitude
             4   N          North/South
             5   00042.24   current Longitude
             6   W          East/West
             7   173.8      Speed in knots
             8   231.8      True course
             9   130694     Date Stamp
             10  004.2      Variation
             11  W          East/West
             12  *70        checksum
eg3. for NMEA 0183 version 3.00 active the Mode indicator field is added
     $GPRMC,hhmmss.ss,A,llll.ll,a,yyyyy.yy,a,x.x,x.x,ddmmyy,x.x,a,m*hh
Field #
1    = UTC time of fix
2    = Data status (A=Valid position, V=navigation receiver warning)
3    = Latitude of fix
4    = N or S of longitude
5    = Longitude of fix
6    = E or W of longitude
7    = Speed over ground in knots
8    = Track made good in degrees True
9    = UTC date of fix
10   = Magnetic variation degrees (Easterly var. subtracts from true course)
11   = E or W of magnetic variation
12   = Mode indicator, (A=Autonomous, D=Differential, E=Estimated, N=Data not valid)
13   = Checksum

$GPVTG: Track Made Good and Ground Speed.

eg1. $GPVTG,054.7,T,034.4,M,005.5,N,010.2,K*48

 

           054.7,T      True course made good over ground, degrees
           034.4,M      Magnetic course made good over ground, degrees
           005.5,N      Ground speed, N=Knots
           010.2,K      Ground speed, K=Kilometers per hour
 
eg2. for NMEA 0183 version 3.00 active the Mode indicator field is added at the end
    $GPVTG,054.7,T,034.4,M,005.5,N,010.2,K,A*25
           A            Mode indicator (A=Autonomous, D=Differential,
                        E=Estimated, N=Data not valid)

 

Responses to “Play Arduino With Global Positioning System (GPS)

  1. I’ve got a simple question : can this shield operate at 5Hz ?
    I need this GPS precision (at least, 10Hz should be perfect in fact) in order to develop my device.

  2. do you have a copy of the sample code. I cannot find it anywhere. I am trying to connect it and get it going for the first time, thanks

  3. Hi. the link is broken.

    Reading the serial, I am getting a info link this:
    $GPRMC,014246.00,A,2306.59453,S,04633.26533,W,0.037,,311013,,,D0

    So as you can see I can get all but no the ALTITUDE. Could you tell me how to solve this?

    Thank you

    • Hi, Rodrigo!!
      How did you get the serial read?? I’m having some problems to communicate with the GPS Shield. I’m using the TinyGPS++ and the SoftwareSerial library on pins 3 and 4, but no success :(
      (Portuguese? Spanish?)

      • I am using the Arduino UNO R3 with the ITEAD GPS shield (U-Blox NEO-6M chip) and had a heck of a time getting it to work….even returned one thinking it was bad. Found a forum that helped to get it working.
        The datasheet says the baud is 38400, but I was not able to get the data using that speed. You need to set/reset the baud on the chip to 4800 and then in the SoftwareSerial.

        ss.begin(38400); // set communication to GPS shield to 38400bps
        ss.print(“$PUBX,41,1,0007,0003,4800,0*13\r\n”); // Change iTead baudrate
        ss.begin(4800); // reset SoftwareSerial baudrate
        ss.flush();

  4. Pingback: Usando o Arduino GPS Shield com Google Earth | Blog FilipeFlop

  5. i got the globalsat gps shield for arduino.
    i connected it, the power led glows on but nothing comes out of the data out port

  6. the links don´t work!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    Please HELP!!!!!!!!!!!!!!
    Ineed access to the SD cardo and found no examples in blog´s!!!!!!!!!!!!!!!!!

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>