The RPy-Rover’s GPS module

While the Euro RPy-Rover  explores new worlds the Command Centre must keep track of its whereabouts. To do this we fitted the rover with a GPS module, that outputs the rover’s coordinates whenever queried.


Locosys LS20031 GPS
Locosys LS20031 GPS

The LS20031 has an integrated ceramic antenna that enables it to acquire a fix from a cold start in 32 seconds. It saves satellite information, so it can acquire a hot-start fix in less than 1 second.


The LS20031 GPS has surface contacts, which are trickier to solder than pins. Of the five contacts on the device we only require three: Vcc, Tx and the Gnd immediatly next to it.

GPS Vcc RPi 1 Vcc 3.3V
GPS Rx Not connected UART RX
Not needed, as we will only listen to the GPS
GPS Tx RPi 10 UART GPS Tx / RPi Rx
GPS Gnd (1) RPi 6 Ground
GPS Gnd (2) Not connected (do not connect)


The GPS used is capable of outputting different NMEA strings. These strings contain different GPS data, such as lattitude, longitude, groundspeed, altitude, etc. According to its manual “The LS20031 GPS receiver module’s firmware is initially set to a 5Hz update rate, a 57600bps serial communication rate, and is set to output GGA, GLL, GSV, GSA, RMC, and VTG NMEA sentences.”

For our project we only needed latitude and longitude, which is present in multiple NMEA strings, including the RMC that is outputted five times per second in the default configuration. By using this string we avoided the need to change the configuration of the device.

To read the GPS device and select RMC strings we used the following code:

def getrmc():

    serial = wp.serialOpen("/dev/ttyAMA0",57600) # open serial port 

    while True: # repeat until we get a RMC NMEA string
        gpsstring = ""
        while True: # repeat until we have a complete string
            if (wp.serialDataAvail(serial) > 0):
		letter = wp.serialGetchar(serial)
                if letter == 10:
                    gpsstring += str(chr(letter))
        if (gpsstring[3:6]=="RMC"):

According to the data sheet of the manufacturer, the RMC string has the following format:

NMEA RMC string syntax
NMEA RMC string syntax

NMEA RMC string example:


The data we want is between the third and seventh comma. We created the following function to parse the string received by the function above and return a string composed of the signed floating values for latitude and longitude, sepparated by a comma.

def cmd_read_GPS():
    # determine the position of the value separating commas
    commas = [0,1,2,3,4,5,6,7,8,9,10,11]
    comnum = 0
    for i in range (0,len(reading)):
        if reading[i] == ",":
            commas[comnum] = i # save the position of the comma
            comnum += 1
    # Extract latitude
    if (reading[commas[3] + 1:commas[4]]) == "N":
        sign = 1
        sign = -1

    degrees = float(reading[commas[2]+1:commas[2]+3])
    minutes = float(reading[commas[2] + 3:commas[3]])/60
    latitude = sign*(degrees + minutes)
    # Extract Longitude
    if (reading[commas[5] + 1:commas[6]]) == "E":
        sign = 1
        sign = -1

    degrees = float(reading[commas[4]+1:commas[4]+3])
    minutes = float(reading[commas[4] + 3:commas[5]])/60
    longitude = sign*(degrees + minutes)


You can download all the Euro RPy-Rover’s code at the project’s GitHub Python repository.

Previous tutorial: Avoiding rover collisions

First tutorial: Controlling the RPy-Rover’s motors

One thought on “The RPy-Rover’s GPS module

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s