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/serial0.
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

And install the software as it prompts you to do.

systemd service fix

Recent Raspberry Pi OS releases (“Jessie” or later) require disabling a 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).  One must 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/serial0 -F /var/run/gpsd.sock

... which will point the gps daemon to our GPS device on the /dev/serial0 port.

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

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

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 gpsd /dev/serial0 -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!

This guide was first published on Dec 26, 2014. It was last updated on Mar 08, 2024.

This page (Use 'gpsd') was last updated on Mar 08, 2024.

Text editor powered by tinymce.