Created
March 1, 2015 21:52
-
-
Save inmcm/1a0e8b80f2d8faff832b to your computer and use it in GitHub Desktop.
Setup Adafruit GPS to Max Data Output and Parse Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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