Open marcelvanherk opened 7 months ago
Here is the sample code I used:
//#include
*/ ///SPI H
File myFile; SPIClass SPISD(3); // ESP32 crashes when 0 or 1 are used; fails with 2 or 3 are used void SD_Init() { // SPIClass SPI2(HSPI);
SPISD.begin(SD_SCK, SD_MISO, SD_MOSI);
if (!SD.begin(SD_CS_PIN,SPISD)) { //SD_CS_PIN this pin is just the dummy pin since the SD need the input
Serial.println(F("failed!"));
return;
}
else Serial.println(F("SD read!"));
myFile = SD.open("/test.txt", "a"); //append to file
if (myFile) { Serial.print("Writing to test.txt..."); myFile.println("testing 1, 2, 3."); myFile.close(); Serial.println("done."); } else { Serial.println("error opening test.txt to write"); } myFile = SD.open("/test.txt", "r"); //read from file if (myFile) { Serial.println("test.txt:"); String inString; //need to use Strings because of the ESP32 webserver while (myFile.available()) { inString += myFile.readString(); } myFile.close(); Serial.print(inString); } else { Serial.println("error opening test.txt to read"); } }
void setup() { // put your setup code here, to run once: Serial.begin(115200); SD_Init(); }
void loop() { // put your main code here, to run repeatedly:
}
Hi,
I found the issue. I wanted to use and therefore enabled PSRAM, which is 8-line SPI on the MON16R8 provided, and as a result GPIO 33-37 cannot be used. Cutting the connection from pin 7 of the SD card (SD_MISO_DAT0) from GPIO35, and rerouting it to pin 47 (for now), makes that both SD card and PSRAM can be used, albeit in 1 bit mode for the SD card. Of course, pin47 can then no longer be used for the touchscreen controller.
The same issue occurs for SD_DAT1 and SD_DAT2 if you want to use the SD card in 4 bit mode.
Hi,
I purchased the ESP32-S3 LCD and it is very nice. However, I have tried in many ways to get the SD card working and failed. Can you share a code snippet on how to do it. I am on ESP32 2.0.14
Thanks