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(){
}