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.
Modify the system-wide GPSD config file to support your serial port.
sudo nano /etc/default/gpsd
A Pi 5 would use:
DEVICES="/dev/ttyAMA0"
All other models of Pi would have a config file that looks like the following:
# Devices gpsd should collect to at boot time. # They need to be read/writeable, either by user gpsd or the group dialout. DEVICES="/dev/serial0" # Other options you want to pass to gpsd GPSD_OPTIONS="-n" # Automatically hot add/remove USB GPS devices via gpsdctl USBAUTO="true"
After updating the configuration file reboot to verify gpsd correctly starts on its own and you can run the following gps related utilities:
- gpsmon
- cgps
- ppstest
sudo reboot
cgps
gpsmon
Enable PPS
PPS uses GPIO pin 4 on the GPS HAT and can work with the same setup using the GPS breakout. You do need to modify the kernel config.txt to support this setup. This means a reboot will be needed after updating the config.txt.
nano /boot/firmware/config.txt # add this to the end of the file dtoverlay=pps-gpio,gpiopin=4
pi@pi5:~ $ sudo ppstest /dev/pps0 trying PPS source "/dev/pps0" found PPS source "/dev/pps0" ok, found 1 source(s), now start fetching data... source 0 - assert 1750357430.000213158, sequence: 13817 - clear 0.000000000, sequence: 0 source 0 - assert 1750357431.000212074, sequence: 13818 - clear 0.000000000, sequence: 0 source 0 - assert 1750357432.000212376, sequence: 13819 - clear 0.000000000, sequence: 0 source 0 - assert 1750357433.000212085, sequence: 13820 - clear 0.000000000, sequence: 0
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:
- GETTING GPS TO WORK ON A RASPBERRY PI.
- GPSD Client How-To ... including examples in C, C++ and Python
- The official GPSD project pages
- A nice writeup of using GPSd with python using threads to make it faster
- Great forum post on how to setup time synchronization with a Raspberry Pi and the PPS output of the GPS HAT.
- Another good write-up on how to configure a Pi to use GPS and the PPS output for time synchronization. Note that this guide uses GPIO18 for the PPS signal but the HAT uses GPIO4.
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!
Page last edited June 19, 2025
Text editor powered by tinymce.