Datasheet
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. 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. 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 . 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
code over the USB drive as normal. Remove the alligator clip, reset the board, and the boot.py will switch to mounting
the internal filesystem as writable so you can log images to it again (but not write any code!).
Remember when you enable USB drive writes (by connecting D5 to ground at startup) you cannot write files to the
internal filesystem and any code in your main.py that attempts to do so (like the example below) will fail. Keep this in
mind as you edit code--once you modify code you need to remove the alligator clip, reset the board to re-
enable internal filesystem writes, and then watch the output of your program.
Datalogging Example Code
The GPS library examples have a datalogging.py file you can edit and save as a main.py on your board:
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)
If you ever get stuck, you can follow the steps mentioned in https://learn.adafruit.com/cpu-temperature-
logging-with-circuit-python/writing-to-the-filesystem to remove boot.py from the REPL if you need to go back
and edit code!
© Adafruit Industries https://learn.adafruit.com/adafruit-ultimate-gps Page 24 of 40










