Skip to main content

Introduction

Documentation Status Discord Build Status Code Style: Ruff

GPS parsing module. Can send commands to, and parse simple NMEA data sentences from serial and I2C GPS modules to read latitude, longitude, and more.

Dependencies

This driver depends on:

Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle.

Installing from PyPI

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:

pip3 install adafruit-circuitpython-gps

To install system-wide (this may be required in some cases):

sudo pip3 install adafruit-circuitpython-gps

To install in a virtual environment in your current project:

mkdir project-name && cd project-name
python3 -m venv .venv
source .venv/bin/activate
pip3 install adafruit-circuitpython-gps

Usage Example

See examples/gps_simpletest.py for a demonstration of parsing and printing GPS location.

Important: Feather boards and many other circuitpython boards will round to two decimal places like this:

>>> float('1234.5678')
1234.57

This isn’t ideal for GPS data as this lowers the accuracy from 0.1m to 11m.

This can be fixed by using string formatting when the GPS data is output.

An implementation of this can be found in examples/gps_simpletest.py

import time
import board
import busio

import adafruit_gps

RX = board.RX
TX = board.TX

uart = busio.UART(TX, RX, baudrate=9600, timeout=30)

gps = adafruit_gps.GPS(uart, debug=False)

gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')

gps.send_command(b'PMTK220,1000')

last_print = time.monotonic()
while True:

    gps.update()

    current = time.monotonic()
    if current - last_print >= 1.0:
        last_print = current
        if not gps.has_fix:
            print('Waiting for fix...')
            continue
        print('=' * 40)  # Print a separator line.
        print('Latitude: {0:.6f} degrees'.format(gps.latitude))
        print('Longitude: {0:.6f} degrees'.format(gps.longitude))

These two lines are the lines that actually solve the issue:

print('Latitude: {0:.6f} degrees'.format(gps.latitude))
print('Longitude: {0:.6f} degrees'.format(gps.longitude))

Note: Sending multiple PMTK314 packets with gps.send_command() will not work unless there is a substantial amount of time in-between each time gps.send_command() is called. A time.sleep() of 1 second or more should fix this.

Documentation

API documentation for this library can be found on Read the Docs.

For information on building library documentation, please check out this guide.

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

Release files for adafruit-circuitpython-gps 4.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for adafruit-circuitpython-gps 4.0.0
File Size Uploaded
adafruit_circuitpython_gps-4.0.0.tar.gz 43.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for adafruit-circuitpython-gps 4.0.0
File Interpreter ABI Platform
adafruit_circuitpython_gps-4.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 56.0 kB

Release files / adafruit_circuitpython_gps-4.0.0.tar.gz

Download URL adafruit_circuitpython_gps-4.0.0.tar.gz
Size 43.0 kB
Tags Source
SHA-256 checksum
How to use checksums
51419d7117ece5db3e335206dab577a3e806122e37b9704e2d4c3d18a52bde10
BLAKE2b-256 checksum
How to use checksums
d4266c8d56a17d5d2df0cf602cd2e689df2fd545f04062e7971d8f48ab77e85e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Release files / adafruit_circuitpython_gps-4.0.0-py3-none-any.whl

Download URL adafruit_circuitpython_gps-4.0.0-py3-none-any.whl
Size 13.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
04a39b098c5abf767bb23d5f69e92f80e7b9833efd15e6c80928e9d3a1075c6e
BLAKE2b-256 checksum
How to use checksums
7c4f51405858f18616785a2ab108b96c9f47c679b4ab4a658725fc2692c18c72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Release history Release notifications | RSS feed

This release

4.0.0 This release

2 release files

3.11.9

2 release files

3.11.8

2 release files

3.11.7

2 release files

3.11.6

2 release files

3.11.5

2 release files

3.11.4

2 release files

3.11.3

2 release files

3.11.2

2 release files

3.11.1

2 release files

3.11.0

2 release files

3.10.9

2 release files

3.10.8

2 release files

3.10.7

2 release files

3.10.6

2 release files

3.10.4

2 release files

3.10.3

2 release files

3.10.2

2 release files

3.10.0

1 release file

3.9.10

1 release file

3.9.9

1 release file

3.9.8

1 release file

3.9.7

1 release file

3.9.6

1 release file

3.9.5

1 release file

3.9.4

1 release file

3.9.3

1 release file

3.9.2

1 release file

3.9.1

1 release file

3.9.0

1 release file

3.8.1

1 release file

3.8.0

1 release file

3.7.1

1 release file

3.7.0

1 release file

3.6.8

1 release file

3.6.7

1 release file

3.6.6

1 release file

3.6.5

1 release file

3.6.4

1 release file

3.6.3

1 release file

3.6.2

1 release file

3.6.1

1 release file

3.6.0

1 release file

3.5.2

1 release file

3.5.1

1 release file

3.5.0

1 release file

3.4.1

1 release file

3.4.0

1 release file

3.3.0

1 release file

3.2.4

1 release file

3.2.3

1 release file

3.2.2

1 release file

3.2.1

1 release file

3.2.0

1 release file

3.1.1

1 release file

3.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page