New ESP32-S3 development board is now available → /products
</>OceanLabz
Beginner~10 min7 Oct 2026 · 3 min read

Testing the SD Card

Test mounting, reading, and writing to a MicroSD card on ESP32 to store audio recordings, system logs, and offline data.

Testing the SD Card

In the previous lessons, you verified that the microphone and speaker on your ESP32 project are working correctly. Now it’s time to test the SD card — the place where you’ll later store logs, audio files, debugging data, and other assets.

This lesson will guide you through connecting an SD card to your ESP32 and testing mounting, reading, and writing data.

#What You’ll Need

Component Purpose
ESP32 Board Runs your code
MicroSD card Storage media
SD card breakout / slot Physical holder
Wires Connect SD to ESP32
USB cable Programming & power

#Wiring the MicroSD Module

Connect your module as follows:

MicroSD Module Pin ESP32 S3/S3 Mini ESP32 ESP32-C3 Function
VCC 3V3 3V3 3V3 Power (Most modules need 3V3)
GND GND GND GND Ground
CS GPIO 42 GPIO 5 GPIO 10 Chip Select
SCK GPIO 2 GPIO 18 GPIO 2 Clock
MOSI GPIO 3 GPIO 23 GPIO 4 Master Out Slave In
MISO GPIO 46 GPIO 19 GPIO 3 Master In Slave Out

#The Test Code

This code uses the standard SD.h library, which is robust and works with almost all ESP32 setups.

[object Promise]

#Common Issues & Fixes

Issue Solution
Card mount failed Check wiring & correct CS pin; ensure card formatted FAT32
Nothing printed Make sure Serial Monitor is 115200 baud
Write fails Ensure card not locked/no write protection
Read back strange data Format card again, try smaller capacity card

Note : Some ESP32 boards use SDMMC internally; if external SPI wiring fails, check your board’s default SD pins and use SD_MMC instead (advanced) — some boards have different defaults.