ESP32 FAQ

ESP32 SD Card: Wiring, Format, Read

// sd card · faq

Filed under: ESP32 · SD Card · Updated August 2026

An SD card turns the ESP32 into a data logger — CSV, audio, photos, even firmware updates. This covers how to connect sd card to esp32 in SPI and SDMMC mode, whether a card is even required, and what size actually works.

How to Connect SD Card to ESP32?

SPI mode, four wires: CS → GPIO5, MOSI → GPIO23, MISO → GPIO19, SCLK → GPIO18, plus 3.3V and GND. Then SD.begin(5) with the SD library and files open like any filesystem. For speed, SDMMC 4-bit mode uses the SD_MMC library with dedicated pins — CMD 15, CLK 14, D0 2, D1 4, D2 12, D3 13 on classic ESP32 — and runs several times faster.

Does the ESP32 require a micro SD card for code?

No — code and assets live in the chip’s own flash memory, and an SD card is optional extra storage. It only matters for data you generate: logs, captured images, audio files, firmware for OTA. The board runs fine without one from the first blink on.

What Size SD Card Is Supported by Freenove ESP32 WROOM?

Up to 32 GB FAT32 in practice. Freenove ESP32-WROOM boards use the standard WROOM-32 module, and the constraint is not the chip — it is the Arduino SD library, which speaks FAT16/FAT32 and chokes on the exFAT that 64 GB and larger cards ship with. Reformat anything bigger as FAT32 and most cards work; a 64 GB Samsung card threw card_init errors on mine until I did exactly that.

What format should the card be?

FAT32, plain and simple. exFAT and NTFS are unsupported by the Arduino SD library, and cards that fail with Card Mount Failed are usually exFAT or have a weird partition layout. Format on a computer first — the card’s factory format is not always FAT32.

Why does SD.begin() fail?

The classic trio: wiring (MISO is the one people skip), voltage (5V breakouts on 3.3V pins), and format (see above). The library prints Card Mount Failed then Failed to open directory — watch the serial monitor, it names the stage that died.

SPI mode or SDMMC mode?

SPI: four wires, any GPIOs, good to maybe 1-2 MB/s. SDMMC 4-bit: six dedicated pins, several MB/s, and it is what you need for recording audio or streaming video. Caveat: the SDMMC pins overlap the camera and PSRAM pins on some S3 boards — check the pinout before designing around speed. The SD pinout guide in the KB lists both modes per board.

How do I read and write a file?

SD.open("/data.csv", FILE_WRITE) creates or truncates; FILE_APPEND keeps existing content and appends. file.println(value) writes a line, and close() flushes. The logging pattern is the same as any filesystem: open, write, close, done.

Can I log sensor data continuously?

Yes — a CSV line per reading is the standard pattern, and one file per day keeps files manageable; logging example projects show the full setup. Two traps: power loss mid-write can corrupt the current file, so flush() before deep sleep, and cheap cards wear out after tens of thousands of writes. Mostly works fine for hobby logging.

Does the SD card need its own power supply?

The 3.3V pin feeds most micro SD modules fine, but writes draw short current spikes that can brown-out the whole board on a weak supply. Add a 100 µF capacitor near the card, or feed the 5V rail through the module’s own regulator if it has one. Random resets during writes are power, not code — the power article goes deeper.

Which SD card should I buy?

A class 10 card, 8-32 GB, brand name. Speed class matters more than capacity — a slow card makes SPI mode feel broken. SanDisk and Kingston class 10 cards have been boringly reliable in every board I have owned; the 4 GB no-name cards from the drawer are the ones that flake.

Mount, Write, List, Read — In Your Browser

The complete SD card bring-up, free and fry-proof:

microSD demo - ESP32
Card ready.
Files on card:
  /log.txt  128 bytes
Wrote /log.txt
Read back: (your data, verbatim)
Done.

Miswire it and you get SD.begin() FAILED - check the wiring — the SPI handshake failure that looks identical on a bench. The formatting and wear-leveling questions from this FAQ sit one layer above exactly what you just watched.

Leave a Reply

Your email address will not be published. Required fields are marked *