I have a DF Robot LCD screen with SD Card reader attached to an Adafruit ESP32-S3 board. The screen is working well, now I'm trying to get the card reader functioning.
The sketch is written in Arduino IDE v2.2.1 on a Windows 11 PC.
The SD card reader starts fine, but will not read or write files. I have tried three cards, all formatted in the SD Card Formatter program - I also tried using the windows format tool.
The code is
#include <SPI.h>
#include <SD.h>
#define TFT_SD 10
void setup() {
Serial.begin(9600);
if (!SD.begin(TFT_SD)){
Serial.println("Card not present or device not working");
while (true);
}
Serial.println("Card found!");
}
void loop() {
File testFile = SD.open("DataTest.txt",FILE_WRITE);
if(testFile){
testFile.close();
Serial.println("File created!");
}
else{
Serial.println("File not created...");
}
testFile = SD.open("DataTest.txt",FILE_WRITE);
if(testFile){
testFile.println("File text goes here.");
testFile.close();
Serial.println("File successfully reopened and written to!");
}
else{
Serial.println("Problem opening the test file...");
}
while(true);
}
The Serial Monitor output is :
Card found!
File not created...
Problem opening the test file...
Any help would be appreciated!