Hi, here is my code to use SD card module with esp32 via arduino IDE. The hardware connections used are default ones.
#include <SD.h>
String fileName;
File dataFile;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
while (!Serial);
delay(5000);
Serial.println("Starting the setup babe");
//SD card initialization
if (!SD.begin(5)) {
Serial.println("SD card initialization failed!");
while (1);
}
Serial.println("SD card is initialized");
SDfile_GenCopy();
}
void loop() {
// put your main code here, to run repeatedly:
}
void SDfile_GenCopy(){
fileName = "nomnom.csv"; //CSV format
dataFile = SD.open(fileName, FILE_WRITE);
// Check if the file opened successfully
if (dataFile) {
Serial.println("File created: " + fileName);
}
else {
Serial.println("Error opening file: " + fileName);
}
dataFile.close();
}
Can you provide any insight as to why its showing this in output serial monitor?
Starting the setup babe
SD card is initialized
Error opening file: nomnom.csv