adafruit_sdcard
- SD card over SPI driver¶
CircuitPython driver for SD cards using SPI bus.
Requires an SPI bus and a CS pin. Provides readblocks and writeblocks methods so the device can be mounted as a filesystem.
Author(s): Scott Shawcroft
Implementation Notes¶
Hardware:
Adafruit MicroSD card breakout board+ (Product ID: 254)
Adafruit Assembled Data Logging shield for Arduino (Product ID: 1141)
Adafruit Feather M0 Adalogger (Product ID: 2796)
Adalogger FeatherWing - RTC + SD Add-on For All Feather Boards (Product ID: 2922)
Software and Dependencies:
Adafruit CircuitPython firmware for the ESP8622 and M0-based boards: https://github.com/adafruit/circuitpython/releases
Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
- class adafruit_sdcard.SDCard(spi, cs, baudrate=1320000)[source]¶
Controls an SD card over SPI.
- Parameters
spi (SPI) – The SPI bus
cs (DigitalInOut) – The chip select connected to the card
baudrate (int) – The SPI data rate to use after card setup
Example usage:
import busio import storage import adafruit_sdcard import os import board spi = busio.SPI(SCK, MOSI, MISO) sd = adafruit_sdcard.SDCard(spi, board.SD_CS) vfs = storage.VfsFat(sdcard) storage.mount(vfs, '/sd') os.listdir('/')
- count()[source]¶
Returns the total number of sectors.
- Returns
The number of 512-byte blocks
- Return type