|
| 1 | +# Simple GPS module demonstration. |
| 2 | +# Will wait for a fix and print a message every second with the current location |
| 3 | +# and other details. |
| 4 | +import time |
| 5 | +import board |
| 6 | +import busio |
| 7 | + |
| 8 | +import adafruit_gps |
| 9 | + |
| 10 | + |
| 11 | +RX = board.RX |
| 12 | +TX = board.TX |
| 13 | + |
| 14 | +uart = busio.UART(TX, RX, baudrate=9600, timeout=30) |
| 15 | + |
| 16 | +gps = adafruit_gps.GPS(uart, debug=False) |
| 17 | + |
| 18 | +gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0') |
| 19 | +# Turn on just minimum info (RMC only, location): |
| 20 | +#gps.send_command(b'PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0') |
| 21 | +# Turn off everything: |
| 22 | +#gps.send_command(b'PMTK314,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0') |
| 23 | +# Tuen on everything (not all of it is parsed!) |
| 24 | +#gps.send_command(b'PMTK314,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0') |
| 25 | + |
| 26 | +gps.send_command(b'PMTK220,1000') |
| 27 | + |
| 28 | +last_print = time.monotonic() |
| 29 | +while True: |
| 30 | + a = gps.update() |
| 31 | + current = time.monotonic() |
| 32 | + if current - last_print >= 1.0: |
| 33 | + last_print = current |
| 34 | + print(a) |
0 commit comments