Datasheet
If you want you can send other custom commands to the GPS module with the send_commandfunction shown above.
You don't need to worry about adding a NMEA checksum to your command either, the function will do this
automatically (or not, set add_checksum=False as a parameter and it will skip the checksum addition).
Now we can jump into a main loop that continually updates data from the GPS module and prints out status. The most
important part of this loop is calling the GPS update function:
Like the comments mention you must call updated every loop iteration and ideally multiple times a second. Each time
you call update it allows the GPS library code to read new data from the GPS module and update its state. Since the
GPS module is always sending data you have to be careful to constantly read data or else you might start to lose data
as buffers are filled.
You can check the has_fix property to see if the module has a GPS location fix, and if so there are a host of attributes
to read like latitude and longitude (available in degrees):
# Initialize the GPS module by changing what data it sends and at what rate.
# These are NMEA extensions for PMTK_314_SET_NMEA_OUTPUT and
# PMTK_220_SET_NMEA_UPDATERATE but you can send anything from here to adjust
# the GPS module behavior:
# https://cdn-shop.adafruit.com/datasheets/PMTK_A11.pdf
# Turn on the basic GGA and RMC info (what you typically want)
gps.send_command('PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
# Turn on just minimum info (RMC only, location):
#gps.send_command('PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
# Turn off everything:
#gps.send_command('PMTK314,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')
# Tuen on everything (not all of it is parsed!)
#gps.send_command('PMTK314,1,1,1,1,1,1,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('PMTK220,1000')
# Or decrease to once every two seconds by doubling the millisecond value.
# Be sure to also increase your UART timeout above!
#gps.send_command('PMTK220,2000')
# You can also speed up the rate, but don't go too fast or else you can lose
# data during parsing. This would be twice a second (2hz, 500ms delay):
#gps.send_command('PMTK220,500')
# Make sure to call gps.update() every loop iteration and at least twice
# as fast as data comes from the GPS unit (usually every second).
# This returns a bool that's true if it parsed new data (you can ignore it
# though if you don't care and instead look at the has_fix property).
gps.update()
© Adafruit Industries https://learn.adafruit.com/adafruit-ultimate-gps Page 22 of 40










