Skip to content

Instantly share code, notes, and snippets.

@reportingsjr
Created November 4, 2018 01:27
Show Gist options
  • Save reportingsjr/078ec7ea81d0d8ee78f7da6b9e32412c to your computer and use it in GitHub Desktop.
Save reportingsjr/078ec7ea81d0d8ee78f7da6b9e32412c to your computer and use it in GitHub Desktop.
circuitpython gps truncation
import board
import busio
import adafruit_gps
import time
uart = busio.UART(board.TX, board.RX)
gps = adafruit_gps.GPS(uart)
# Turn on the basic GGA and RMC info (what you typically want)
gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
# Set update rate to once a second (1hz) which is what you typically want.
gps.send_command(b'PMTK220,1000')
last_loop = time.monotonic()
while True:
gps.update()
current_loop = time.monotonic()
if current_loop - last_loop < 1.0:
continue
last_loop = current_loop
if not gps.has_fix:
print('Waiting for fix')
continue
# We have a fix! (gps.has_fix is true)
print('lat={} lon={}>\n'.format(gps.latitude, gps.longitude))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment