Skip to content

GPS Software Setup

Anton Nikitenko edited this page Oct 17, 2021 · 4 revisions

GPS Setup for Software Team

Device

For capturing GPS coordinates and additional data, we are currently using the Ultimate GPS CP2104 USB Module. This version allows us to connect the module to a computer (such as a Raspberry PI) with only a Micro-USB to USB cable. This module shall thus be installed by connecting it to the Raspberry Pi for runtime operations. There is another version of the module which requires you to solder the pins required to transmit and receive data to the computer, the Ultimate GPS Breakout Board, but the one we are using is the Ultimate GPS USB Board.

Software Setup

Follow the steps outlined in the following online guide to connect the GPS to a computer (such as a Raspberry Pi) and to start receiving data: https://learn.adafruit.com/adafruit-ultimate-gps-on-the-raspberry-pi/

Testing

The following code was taken from a tutorial on setting up this GPS module:

import gps

# Listen on port 2947 (gpsd) of localhost
session = gps.gps("localhost", "2947")
session.stream(gps.WATCH_ENABLE | gps.WATCH_NEWSTYLE)

while True:
    try:
        report = session.next()
        # Wait for a 'TPV' report and display the current time
        # To see all report data, uncomment the line below
        # print(report)
        if report['class'] == 'TPV':
            if hasattr(report, 'time'):
                print(report.time)
    except KeyError:
        pass
    except KeyboardInterrupt:
        quit()
    except StopIteration:
        session = None
        print("GPSD has terminated")
Clone this wiki locally