Beaglebone Black GPS Tracker LESSON 3: Parsing the NMEA Sentences in Python

Beaglebone GPS
Beaglebone Black connected to the Adafruit Ultimate GPS

In the first two lessons in this series, you learned how to hook the Beaglebone Black to the Adafruit Ultimate GPS breakout board. We then learned to read NMEA sentences from the GPS, and how to control the data the GPS spits out. In this lesson we will learn to parse the NMEA sentences into useful data. You need to make sure you go back and review the first two lessons, as this one draws heavily on those. Also, you need to start with the code we had developed in LESSON 2. (If you need the gear we are using, you can get the Beaglebone Black HERE, and you can get the Adafruit GPS HERE.)

In this code we move most of the work up into our GPS class. That makes the main part of the program simple and intuitive to use.


10 thoughts on “Beaglebone Black GPS Tracker LESSON 3: Parsing the NMEA Sentences in Python”

  1. Hi

    I have you first let you know that your tutorial has helped me a lot to understand python programming and programming Beaglebone. You have a very eloquent way of explaining complicated things. I’m sure the students love you over there.

    I do have one question. In this code there is a if statement
    if myGPS.fix != 0:
    Since the data we got from Beaglebone is string, shouldn’t 0 be inside ” “??

    Thanks once again.

  2. Excellent tutorial, really helpful. Not only am I now able to obtain the data I need from this excellent device, but I had a lightbulb moment with how classes work which is something I’ve tried to understand for a while. Thanks!

  3. Hello,

    I am getting an error code. I am dealing with a prebuilt image called MachineKit that is Debian based. It was produced around March of 2016.

    I think the Adafruit people are having trouble (or something). I cannot update or upgrade specific items that are called to my attention. Oh and here it is:

    Traceback (most recent call last):
    File “”, line 4, in
    RuntimeError: Unable to export UART channel.

    That is what keeps repeating when I run the above software.

    I tried to get Adafruit_BBIO and the UART set-up complete. If there are any people on this site that deal with my issue, please try to contact me.


    1. The primary thing you have to do is make sure you can simply read from the UART pin into python on the Beaglebone Black. That should not be anything to do with Adafruit libraries. Did you follow the instructions on the video to read from the UART pins?

      1. I think so. I will check again. Thank you for replying. I will get back to you on my advancement.


    2. Hello,

      I figured out what my issues are with the BBGW. I need to use UART2 instead of UART1. Sorry for the inconvenience.


  4. Hello, your tutorial is very interesting, but please if , is it possible to do the same with gps GY-GPSMV2

  5. Slight tweak to the code:
    The if statement regarding whether or not we print based on having a fix does need to be if ” myGPS.fix!=’0′ ” (with the quotes since it is a string).

    Awesome tutorials!! Thank you!

  6. This code applies to all GPS’. I used it on the Pixhawk’s Ublox M8N and it worked. I had to make some changes on the code because the NMEA messages were a little bit different from these in the tutorial. Ex: My gps sends GNRMC and GNGGA instead of GPRMC and GPGGA. In addition, the position and number of the characteres after the comma in the latitude, longitude and time are different.

    However, the major difference of one gps to another is that these command messages change, so you won’t be able to use these in your device. You will need your gps receiver’s datasheet in order to find out what messages you will need to command your device.
    Baud rate might change as well.

  7. Great Video series. How did you figure out the statements to send to the GPS to change its update, rates, measure rates, baudrate ect?

Comments are closed.