Raspberry Pi GPS

GPS Data logger using a BerryGPS

This post explains how to log GPS data from a BerryGPS or a BerryGPS-IMU and then how to plot this data onto Google Maps and many other maps E.g. OpenStreet, WorldStreet, National Maps, etc..

Raspberry Pi GPS

1. Setup GPS

Follow the instructions on this page to setup your Raspberry Pi for a BerryGPS. Ensure GPSD is set to automatically start and confirm that you can see the NMEA sentences when using gpsipe;

pi@raspberrypi ~ $ gpspipe -r


2.  Automatically Capture Data on Boot.

We will be using gpspipe to capture the NMEA sentence from the BerryGPS and storing these into a file. The command to use is;

pi@raspberrypi ~ $ gpspipe -r -d -l -o /home/pi/`date +”%Y%m%d-%H-%M-%S”`.nmea

-r = Output raw NMEA sentences.
-d = Causes gpspipe to run as a daemon.
-l = Causes gpspipe to sleep for ten seconds before attempting to connect to gpsd.
-o = Output to file.

The date the file is created is also added to the name.

Now we need to force the above command to run at boot. This can be done by editing the rc.local file.

pi@raspberrypi ~ $ sudo nano /etc/rc.local


Just before the last line, which will be ‘exit 0’, paste in the below line;

gpspipe -r -d -l -o /home/pi/`date +"%Y%m%d-%H-%M-%S"`.nmea

Reboot and confirm that you can see a .nmea file in the home directory.

Every time the Raspberry Pi is rebooted, a new file will be created.

BerryGPS Raspberry Pi GPS

3. Collect Some Data

Go and collect some data. For this post, I used a BerryGPS sitting on a Raspberry Pi Zero and I placed it on the dashboard of my car.

I was able to confirm that the GPS had a fix by the flashing fix LED.


4. Plot the Data

We will use www.gpsvisualizer.com to plot the route we collected.

www.gpsvisualizer.com will accept the raw NMEA file.

Its best to use this page as you will be able to configure a number of options before you upload;



Below is an example route I took;
GPS plotter



5. Change Track Data

GPS Visualizer can colorize your tracks according to speed, elevation, or some other unit.
This can be done by selecting the value in the drop down box highlighted below;

GPS Visualizer Raspberry Pi
Track Option


Here are two examples, speed and number of satellites;

Number of Satellites


6. Display the Route in Google Earth

www.gpsvisualizer.com can also be used to convert your raw NMEA file into a GPX file which then can be used with Google Earth.

Raspberry Pi Google Earth

Use this URL;

Upload you file, make sure GPX is selected and then click the convert bottom. Once converted, download the GPX file and open it in Google Earth.

To show the elevation and speed profile of your route within Google Earth, right click the track and select ‘Show Elevation Profile’

Raspberry Pi Google Earth
Google Earth Elevation and Speed Profile

5 thoughts on “GPS Data logger using a BerryGPS”

  1. In order to automatically capture data on boot I had to add the ‘sleep 60’ line and additional blank lines in the /etc/rc.local.

    # Line purposefully left blank
    sleep 60
    gpspipe -r -d -l -o /home/pi/`date +”%Y%m%d-%H-%M-%S”`.nmea
    # Line purposefully left blank
    exit 0

    This worked for me using GPS Timing Antenna + 10 Meter Cable SMA, HAB-GPSPI-NAN, and Raspberry Pi 3.

  2. I have found that the device only begins automatically when I am connected to my home wifi. It will not connect when there is no wifi or I am connected to my mobile hotspot. I can manually start it via SSH. Does anyone have a solution or where this problem might be originating from?

  3. Isn’t there a cpp program (just like berryIMU) that can get GPS data and print it out?
    I don’t want to record it. I need to know the latitude, longitude and altitude

  4. Hi there,
    This has exactly what I’m looking for… I want to track flights in a light aircraft.
    The one thing I would like to see (optional extra?) is a gsm module so I can have the flight data sent home automatically without having to be there.
    What are the chances of such a thing happening? If not, would an existing gsm module be able to live together on the same Pi? Sorry I’m not much of a hardware guy!

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.