Use 'gpsd'

You can always just read that raw data, but its much nicer if you can have some Linux software prettify it. We'll try out gpsd which is a GPS-handling Daemon (background-helper)

Installing a GPS Daemon (gpsd)

The first step is installing some software on your Raspberry Pi that understands the serial data that your GPS module is providing via /dev/ttyAMA0.
Thankfully other people have already done all the hard work for you of properly parsing the raw GPS data, and we can use (amongst other options) a nice little package named 'gpsd', which essentially acts as a layer between your applications and the actual GPS hardware, gracefully handling parsing errors, and providing a common, well-defined interfaces to any GPS module.

To install gpsd, make sure your Pi has an Internet connection and run the following commands from the console:

sudo apt-get update
sudo apt-get install gpsd gpsd-clients python-gps

And install the software as it prompts you to do.

Raspbian Jessie systemd service fix

Note if you're using the Raspbian Jessie or later release you'll need to disable a systemd service that gpsd installs.  This service has systemd listen on a local socket and run gpsd when clients connect to it, however it will also interfere with other gpsd instances that are manually run (like in this guide).  You will need to disable the gpsd systemd service by running the following commands:

sudo systemctl stop gpsd.socket
sudo systemctl disable gpsd.socket

Should you ever want to enable the default gpsd systemd service you can run these commands to restore it (but remember the rest of the steps in this guide won't work!):

sudo systemctl enable gpsd.socket
sudo systemctl start gpsd.socket

Try out 'gpsd'

After installing gpsd and disabling the gpsd systemd service as mentioned above you're ready to start using gpsd yourself.

Start gpsd and direct it to use HW UART. Simply entering the following command:

sudo gpsd /dev/ttyAMA0 -F /var/run/gpsd.sock

... which will point the gps daemon to our GPS device on the /dev/ttyAMA0 console

Try running gpsmon to get a live-streaming update of GPS data!

or cgps which gives a less detailed, but still quite nice output

cgps -s
Don't forget, you do need to have FIX to use these tools! If you have FIX and cgps always displays 'NO FIX' under status and then aborts after a few seconds, you may need to restart the gpsd service. You can do that via the following commands:
sudo killall gpsd
sudo gpsd /dev/ttyAMA0 -F /var/run/gpsd.sock

More info!

You can use gpsd to help  you read data into other programming languages like C and Python using a variety of existins libraries

The following tutorials may be useful to you if you want to dig into this a bit further, and do something a bit more advanced with your GPS data:

Doing something fun with GPS and tracking data? Be sure to post about it in the Adafruit forums so everyone else can get inspired by it!

Last updated on 2016-03-28 at 04.24.22 PM Published on 2014-12-26 at 05.22.11 PM