Let's Make Robots!

GPS - The Complete Guide - Arduino based Global Positioning System

Use an Arduino GPS Shield to Fix position,altitutude,time,date........

GPS:- The Complete Guide to Global Positioning Systems.

Blogged Here :- Guide to Global Positioning Systems.  

Check also:- Fundamentals of a GPS guided vehicle ( patrickmccabe)

How they Work and How to interface them into your Robot.

Does your Robot need to fix its absolute Position - Speed - Heading - Time - Date & Altitude.


Here is a Guide to explain the Process.


GPS satellites (presently totalling 31) orbit the Earth at an approx. altitude of 20,000Km.

For a GPS unit to fix its location it needs to receive at least 3 satellites

The GPS signal that is transmitted from each satellite contains:-


Time.        down to the millisecond range (GMT-referenced).
Position.   accuracy 2 to 3 meters.
Altitute.
Date.

From this information it is also possible to work out Compass Heading and Speed.

 

 


What follows below is an Arduino based system that i can Highly recommend.

It is very easy to interface into projects.

It is a compact robust system and very reliable.


I will be using a GPS Shield using the USGlobalSat EM-406A receiver

This Shield has also a data logging facility that saves to an SD card .

 


 This walk through is in three parts :-


 Part 1 :- using a serial port to retrieve data from a GPS unit


Setting up the basic system - (i included the first part because it is possible to talk directly to the GPS via its serial port just by connecting a FTDI cable direct to the GPS sheild board .)

 

So for the first part we will be using just the serial port of the Arduino as an example.

Remove the ATMEGA chip on the Arduino Board (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 Arduinos serial port to read the data.

 

 

Then wire the  GPS unit so:-

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

The GPS unit can be attached to the Arduino and the USB connected.
Select the Arduinos Serial Port and adjust the speed to 4800 Baud.


The resulting output stream looks a bit like 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 2 :- How can we make use of this information by using an Arduino Script.


Remove the Jumper off the Arduino and Plug the ATMEGA chip back in and install the GPStest_RMC.pde script.

 

Dont forget to install a AFSoftSerial.h library into the Hardware/Libraries

 


Then wire the  GPS unit so (picture above) :-

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



Open up the Arduinos 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 has extracted the data (in Bold) into variables which can be used in your normal programming.

Its as simple as that.


Part 3:- Third party Software.


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.

 

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

 

 

 and here is another

 

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

.... ahha i just noticed it has an external antenna ..... check ...or better still resolder the antenna connections making sure that the outer braid and inner wire are not shorted.....

NB. normally Antenna cable has an impedence matched to the internal receiver... ie so extra wire in addition to the antenna cable can cause problems.

I resoldered the antenna but still no improvement inside ,though I cant test it outside now because its raining.

Can i connect a gps module and a xbee module simultaneously to my arduino ?

Because i saw that both of them use the rx and tx pins .

Is that possible?

I have no experience with xbees, however the Arduino Mega has a handfull of spare RxTx inputs - maybe they could be used.

No - my system worked well from the start and  i must say is quite "bombproof"

Some pointers - sorry if its basic -----

(1) GPS unit must be outside - or at least on the window ledge so it can see "Clear Sky" , no metal work or building close by.

the unit is pretty fast to locate satelites and data comes for sure within 30seconds or so...

during data logging the fix can take a little longer from coldstart but this is less than a minute.

(2) Go back to basics - ie Part 1 i described above - removing the arduino chip and using the arduinos circuit board to read the Raw data - if this does not work then double check your soldering for "Dry joints" etc. 

(3) what leds are flash on the GPS unit and also on the arduino board.

(4)if you have SD card installed ...remove it and see if this helps.

hope this helps - pleae let me know how you get on

I already removed the Arduino chip (as you described) but with the same result, i.e. receiving no (raw) data. I also checked the soldering properly. Maybe the problem is the receiver itself, although it's new. The red LED on it is on, sometimes blinking. By the way, the two LEDs on the shield are always off.

Of course, I'll let you know how I get on solving the problem!

After checking all the details/parts of the board, it turned out that the problem was a jumper which did not work properly. After replacing it, I could receive GPS data! Time-consuming but very simple in the end ;-)

I'm now trying to store the data on an SD card.

I am well pleased for you, the square header sockets are not so good at holding round wire :-(

The Gps unit is very accurate, even under tree cover - once you have some data on your SD card throw the data into this site http://www.gpsvisualizer.com/ 

It will draw a map of the data overlayed onto various maps (googlearth etc)

Good luck and if you find any other interesting capabilities - links etc  let me know and i can update this walkthrough for all to profit.

Thanks for the great post!

I'm using the same hardware you did (i.e. a GPS Shield and the USGlobalSat EM-406A receiver). After assembling, I ran the tests you described here. The problem is that I do not get any output stream! I can upload the test program to the Arduino board, but no data is received via the GPS receiver.
Did you also have trouble like that? Or do you have any idea what the problem might be (I assume soldering is done well)?

Perfect, I will help you with your GPS code.