This is the documentation for the latest development branch of MicroPython and may refer to features that are not available in released versions.

If you are looking for the documentation for a specific release, use the drop-down menu on the left and select the desired version.

machine.SDCard

Classes

SDCard

This class provides access to SD or MMC storage cards using either

Module Contents

class machine.SDCard.SDCard(slot=1, width=1, cd=None, wp=None, sck=None, miso=None, mosi=None, cs=None, freq=20000000)

This class provides access to SD or MMC storage cards using either a dedicated SD/MMC interface hardware or through an SPI channel. The class implements the block protocol defined by vfs.AbstractBlockDev. This allows the mounting of an SD card to be as simple as:

vfs.mount(machine.SDCard(), "/sd")

The constructor takes the following parameters:

  • slot selects which of the available interfaces to use. Leaving this unset will select the default interface.

  • width selects the bus width for the SD/MMC interface.

  • cd can be used to specify a card-detect pin.

  • wp can be used to specify a write-protect pin.

  • sck can be used to specify an SPI clock pin.

  • miso can be used to specify an SPI miso pin.

  • mosi can be used to specify an SPI mosi pin.

  • cs can be used to specify an SPI chip select pin.

  • freq selects the SD/MMC interface frequency in Hz (only supported on the ESP32).