ESP32 C3 mini/pico: can't get SD card to work
Posted: Wed Sep 06, 2023 9:15 pm
I'm unable to get sd.begin to start successfully on a C3 pico when connected to an SD card shield. The same shield works when connected to a D1 pro processor, so I know the SD card shield is working. From my studies I think I've specified the pins correctly in this sketch. Any suggestions for how to get this working would be appreciated. Sketch is from the esp32/sd example with the file system tests removed and the pin info for the C3 added. It always fails with "Card Mount Failed".
Code: Select all
/*
* Connect the SD card to the following pins:
*
* SD Card | ESP32 (Lolin C3 pico pins)
* D2 -
* D3 SS aka CS (IO5)
* CMD MOSI (IO4)
* VSS GND
* VDD 3.3V
* CLK SCK (IO1)
* VSS GND
* D0 MISO (IO0)
* D1 -
*/
#include "FS.h"
#include "SD.h"
#include "SPI.h"
// PINS for C3 mini or C3 pico
#define SCK 1
#define MISO 0
#define MOSI 4
#define SS 5
SPIClass spi = SPIClass();
void setup(){
Serial.begin(115200);
spi.begin(SCK, MISO, MOSI, SS);
if(!SD.begin(SS,spi)){
Serial.println("Card Mount Failed");
return;
}
uint8_t cardType = SD.cardType();
if(cardType == CARD_NONE){
Serial.println("No SD card attached");
return;
}
Serial.print("SD Card Type: ");
if(cardType == CARD_MMC){
Serial.println("MMC");
} else if(cardType == CARD_SD){
Serial.println("SDSC");
} else if(cardType == CARD_SDHC){
Serial.println("SDHC");
} else {
Serial.println("UNKNOWN");
}
uint64_t cardSize = SD.cardSize() / (1024 * 1024);
Serial.printf("SD Card Size: %lluMB\n", cardSize);
}
void loop(){
}