This guide will show you how to setup the GPS add-on on a CodeBug Connect.


You need a later version of the eMicroPython system software running on your CodeBug Connect to use the GPS add-on. It’s easy to update your system software.

GPS works by receiving radio signals from satellites orbiting the earth.

GPS Satellite in space

GPS signals are received from a constellation of satellites in space.

Before a position can be found it needs to receive information from multiple satellites. When first powered on, a lot of information needs to be received before the signal ‘locks on’. Buildings, trees, etc. which block signals will make it harder to get a lock, and as such, receivers will work best when outdoors with a clear view of most of the sky.


Get outside with a clear view of most of the sky for best results.


Take care when plugging in add-ons. Always disconnect the power, check all the pins are aligned and never use excessive force.

  1. Ensure the power is disconnected

  2. Make sure everything is the right way up. The square GPS antenna should be on the same side as CodeBug Connect display.

  3. Check all the pins are aligned and gently slide in.

  4. Power up your CodeBug Connect

The GPS add-on will start looking for satellites as soon as it is powered on. The small LED will flash once a second when it has got a good lock.


Check your CodeBug Connect eMicroPython version. This code will only work with eMicroPython later than version 1.2.

Run the following code:

import cbc
from inventthings import gps
import time

#wait until locked onto satelite
while not gps.gps_sensor.fix_valid:

#once locked on, scroll lat and lon
lat = gps.deg_decmin_to_dec_deg(
lon = gps.deg_decmin_to_dec_deg(gps.gps_sensor.lon)
cbc.display.scroll_text("{},{}".format(str(lat), str(lon)))

GPS positions are given as a latitude and longitude. Latitude describes how far North or South (with 0 being the equator and increasing going north). Longitude describes how far East or West of a line in Greenwich, London, UK.

Latitudes and longitudes are measured in degrees. These degrees can be split up in different ways, as decimals, or as minutes and decimal-minutes, or as minutes, seconds and decimal seconds.

To get the latitude in degrees minutes and decimal degrees:

You’ll see a result in the following format:

(53, 28.7694)

To get the longitude in degrees minutes and decimal degrees:


You’ll see a result in the following format:

(-2, 14.7069)

This means the GPS has position is 53° 28.7694, -2° 14.7069. Enter the coordinates into your favourite online map e.g. Google Maps and you should see your position shown on the map.

If you’d prefer the position as decimal degrees use the conversion function:


Now you’ve seen how to get started with the GPS add-on there’s lots of possibilities. You could:

Check out the reference documentation for the add-on to learn more.