Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jeffkarney/fdd2dcf1748dd2ca97cfbb1522ad57e1 to your computer and use it in GitHub Desktop.
Save jeffkarney/fdd2dcf1748dd2ca97cfbb1522ad57e1 to your computer and use it in GitHub Desktop.
Setup Adafruit GPS to Max Data Output and Parse Test
from pyb import UART
from micropyGPS import MicropyGPS
import mtk
# Instatntiate the micropyGPS object
my_gps = MicropyGPS()
print('Setting Up UART to 9600bps')
baud = 9600
uart = UART(3, baud)
print('Changing UART Speed to 115200bps')
baud = 115200
uart.write(mtk.update_baudrate(baud))
pyb.delay(1500)
uart.deinit()
uart = UART(3, 115200,read_buf_len=512)
print('Changing NMEA Rate to 10Hz')
uart.write(mtk.update_nmea_rate(10))
print('Parsing....')
# Continuous Tests for characters available in the UART buffer, any characters are feed into the GPS
# object. When enough char are feed to represent a whole, valid sentence, stat is set as the name of the
# sentence and printed
while True:
if uart.any():
stat = my_gps.update(chr(uart.readchar())) # Note the conversion to to chr, UART outputs ints normally
if stat:
print(stat)
stat = None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment