Created
September 13, 2024 17:42
-
-
Save 0xD34D/52b1bce570c5bef6f94090808b423bfa to your computer and use it in GitHub Desktop.
Getting SD card working on unknown AliExpress ESP32 with round display
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Arduino.h> | |
#include <SdFat.h> | |
// SD card pins | |
#define SD_CS_PIN GPIO_NUM_13 | |
#define SD_CLK_PIN GPIO_NUM_14 | |
#define SD_MOSI_PIN GPIO_NUM_15 | |
#define SD_MISO_PIN GPIO_NUM_2 | |
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, USER_SPI_BEGIN, SD_SCK_MHZ(16)) | |
SdFat sd; | |
void setup() { | |
Serial.begin(115200); | |
Serial.print("Starting"); | |
for (uint8_t i = 0; i < 10; i++) { | |
Serial.print("."); | |
delay(500); | |
} | |
Serial.println(""); | |
SPI.begin(SD_CLK_PIN, SD_MISO_PIN, SD_MOSI_PIN, SD_CS_PIN); | |
if (!sd.begin(SD_CONFIG)) { | |
Serial.println("SD card mount failed!"); | |
return; | |
} | |
uint8_t cardType = sd.card()->type(); | |
Serial.print("SD Card Type: "); | |
if (cardType == 0) { | |
Serial.println("SD V1"); | |
} else if (cardType == 1) { | |
Serial.println("SD V2"); | |
} else if (cardType == 3) { | |
Serial.println("SDHC/SDXC"); | |
} else { | |
Serial.println("UNKNOWN"); | |
} | |
} | |
void loop() { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment