Datasheet

latitude, longitude, and timestamp are usually always available (if you're using the example as-is) but they might not
be if you turn off those outputs with a custom NMEA command!
That's all there is to reading GPS location with CircuitPython code!
Datalogging Example
Another handy task with GPS is logging all the raw output of the GPS module to a file. This is useful if you're importing
the GPS data into a tool like Google Earth which can process raw NMEA sentences. You can perform this datalogging
very easily with CircuitPython.
To store data you'll need to choose one of two options:
Wire up a SD card holder to your board's SPI bus, or use a board with SD card holder built-in like the Feather M0
Adalogger (https://adafru.it/weP). This is the recommended approach as it gives you a lot of space to store data
and you can easily copy the data to your computer from the card.
Store data in your board's internal filesystem. This requires a little more setup but allows you to save to a file on
the internal filesystem of your CircuitPython board, right next to where code and other data files live. This is
more limited because depending on your board you might only have a few kilobytes or megabytes of space
available and GPS sentences will quickly add up (easily filling multiple megabytes within a few hours of logging).
Install SD Card Library
If you're storing data on a SD card you must ensure the SD card is wired to your board and you have installed the
Adafruit SD card library. Luckily there's an entire guide to follow to learn about this process of connecting a SD card
and installing the necessary library (https://adafru.it/BuU). Be sure to carefully follow the guide so the card is
connected, library installed, and you can confirm you're able to manually write data to the card from the Python prompt.
Enable Internal Filesystem Writes
If you're storing data on the internal filesystem you must carefully follow the steps in the CPU temperature logging
guide to enable writing to internal storage (https://adafru.it/BuV). If you're writing to a SD card skip these steps and
move on to look at the datalogging code below. Edit the boot.py on your board (creating it if it doesn't exist) and add
these lines:
Remember once you remount("/") you cannot edit code over the USB drive anymore! That means you can't
edit boot.py which is a bit of a conundrum. So we configure the boot.py to selectively mount the internal filesystem as
writable based on a switch or even just alligator clip connected to ground. Like the CPU temperature guide
shows (https://adafru.it/BuV) . In this example we're using D5 but select any available pin.
This code will look at the D5 digital input when the board starts up and if it's connected to ground (use an alligator clip
or wire, for example, to connect from D5 to board ground) it will disable internal filesystem writes and allow you to edit
import digitalio
import board
import storage
switch = digitalio.DigitalInOut(board.D5)
switch.direction = digitalio.Direction.INPUT
switch.pull = digitalio.Pull.UP
# If the D5 is connected to ground with a wire
# you can edit files over the USB drive again.
storage.remount("/", not switch.value)
© Adafruit Industries https://learn.adafruit.com/adafruit-ultimate-gps-featherwing Page 22 of 34