I'm currently working on a project using an ESP32 (the Waveshare ESP32 Driver Board), and I am trying to read data from an SD card, but consistently getting a "SD Card Mount Failed" error. I am using the Adafruit SD card reader breakout board and the Arduino IDE.
Here's how I've wired the SD card reader to the ESP32
SD card ESP32
------- -----
3.3V 3.3V
GND GND
CLK pin 18 (SCK)
DO pin 19 (MISO)
DI pin 23 (MOSI)
CS pin 5 (SS)
And here's the relevant code I'm using to setup and test the SD card:
#define SCK 18
#define MISO 19
#define MOSI 23
#define CS 5
int setup_sd_card() {
SPIClass spi = SPIClass(VSPI);
spi.begin(SCK, MISO, MOSI, CS);
if (!SD.begin(CS,spi,80000000)) {
Serial.println("ERROR: SD Card Mount Failed");
return -1;
}
uint8_t cardType = SD.cardType();
if(cardType == CARD_NONE){
Serial.println("ERROR: No SD card attached");
return -1;
}
// Code to print out SD card details...
return 1;
}
I've triple-checked my wiring but the code always fails at if (!SD.begin(CS,spi,80000000))
. I've tried 3 different SD cards of different sizes, all formatted to FAT32 (64GB, 256GB, 1024GB)
Could the issue be related to the ESP32 not being a stock one because it has some hardware for driving an e-paper screen? Here is the schematic: https://www.waveshare.com/w/upload/8/80/E-Paper_ESP32_Driver_Board_Schematic.pdf
Can anyone suggest what might be the issue or what else I could try to debug this problem? Any help would be greatly appreciated.