In this section, we develop a simple program to access a microSD card from the ESP32. For the demo, I use the ESP-WROVER-KIT v4 board. Fortunately, the ESP-WROVER-KIT v4 board has a built-in microSD card breakout that is connected to SDMMC pins.
Your ESP32 board should be connected to the microSD card breakout to perform this demo. You also need a microSD storage card with a small size, such as 1 GB, 2 GB or 4 GB. Your microSD card storage should be formatted as FAT.
Our demo scenario is aimed at creating a file named test.txt on a microSD card. Then, we read the content of the test.txt file and print this to the serial Terminal.
Now, you can create an ESP32 project called sdcard. Our main project file is sdcard.c and is located in the main folder. Firstly, we declare all required header files, including sdmmc and sdspi: