Datasheet

Next connect to the board's serial REPL so you are at the CircuitPython >>> prompt.
Initialize & Mount SD Card Filesystem
Before you can use the microSD card you need to initialize its SPI connection and mount its filesystem. First import the
necessary modules to initialize the SPI and CS line physical connections:
Next create the SPI bus and a digital output for the microSD card's chip select line (be sure to select the right pin name
or number for your wiring):
Now import modules to access the SD card and filesystem:
At this point you're ready to create the microSD card object and the filesystem object:
Notice the adafruit_sdcard module has a SDCard class which contains all the logic for talking to the microSD card at a
low level. This class needs to be told the SPI bus and chip select digital IO pin in its initializer.
After a SDCard class is created it can be passed to the storage module's VfsFat class. This class has all the logic for
translating CircuitPython filesystem calls into low level microSD card access. Both the SDCard and VfsFat class
instances are required to mount the card as a new filesystem.
Finally you can mount the microSD card's filesystem into the CircuitPython filesystem. For example to make the path
/sd on the CircuitPython filesystem read and write from the card run this command:
The first parameter to the storage.mount command is the VfsFat class instance that was created above, and the
second parameter is the location within the CircuitPython filesystem that you'd like to 'place' the microSD card.
Remember the mount location as you'll need it to read and write files on the card!
Reading & Writing Data
import board
import busio
import digitalio
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
# Use board.SD_CS for Feather M0 Adalogger
cs = digitalio.DigitalInOut(board.SD_CS)
# Or use a GPIO pin like 15 for ESP8266 wiring:
#cs = digitalio.DigitalInOut(board.GPIO15)
import adafruit_sdcard
import storage
sdcard = adafruit_sdcard.SDCard(spi, cs)
vfs = storage.VfsFat(sdcard)
storage.mount(vfs, "/sd")
© Adafruit Industries https://learn.adafruit.com/adafruit-adalogger-featherwing Page 29 of 36