01 Overview
SD cards are the go-to removable storage for field devices: non-volatile, high capacity, and readable by any PC. This example shows how to read and write SD cards from an ESP32 using SDMMC or SPI mode, covering the full path from hardware wiring to software mounting.
Use it for long-term logging of runtime data or sensor readings, or for exporting configuration and firmware backups to a customer. The FAT filesystem is natively recognized by Windows/macOS, so no special tools are needed.
SDMMC mode uses a dedicated peripheral with a 4-bit parallel data bus, offering high throughput for large data volumes. SPI mode reuses the common SPI bus with fewer pins, but is slower—suitable for small data or pin-constrained designs.
If you only need to store a few configuration bytes, skip the SD card—use the NVS partition instead. It's simpler, more reliable, and saves power. SD cards are for 'big files' and 'removable' scenarios.
Hot-plugging is a hidden pitfall in SD design: mechanical contacts, power sequencing, and filesystem state all need attention. This example highlights these risks and gives engineering recommendations.