.. module:: sdcard :synopsis: SD card :mod:`sdcard` --- SD card ================================================== Secure Digital or SD cards and micro microSD cards are inexpensive and can add a large amount of storage space to a device. MicroPython has only 1M of flash to store code and data. If you have larger flash space, you can connect a micro SD card to the mPython Board via SPI communication to expand its storage space. .. note:: SD card -- the image must be viewed online: `520920e2-79cd-4b23-8e89-1acc572496e8 `__ SDCard Class ------------- .. Class:: SDCard(spi, cs) Create an SDCard object and initialize the SD card. First, ensure that the pins of the SPI bus are physically connected correctly to the micro SD card. Make sure your micro SD card is formatted with the FAT or FAT32 file system. Then, use os.mount() to mount the SD card's new virtual FAT file system to the specified directory. After mounting, you can use Python's file operations (such as open, close, read, and write) to access files. - ``spi`` - The machine.SPI object - ``cs`` - The CS control pin of the SPI .. literalinclude:: /_static/products/mpython-s3/_static/examples/file/sdcard.py :caption: Example - Mount an SD card :linenos: .. literalinclude:: /_static/products/mpython-s3/_static/examples/file/print_directory.py :caption: Example - List all files :linenos: