ArduinoA
Arduino4d ago
1 reply
jinn

ESP32 S3 N16R8 with MicroSD Card Adapter Module - Initialization failed (help)

Serial Monitor Output:
Initializing SD card...
SD card initialization failed!
==============================================
MOSI: 11
MISO: 13
SCK: 12
SS or CS: 10



For some reason I tried everything and search forums and discussions about this problem where it can't initialize with the ESP32 S3 for some reason

What I tried:
- Check the output voltage on my ESP32 S3 on the 3.3V and 5Vin pins
- Format my MicroSD Card to FAT32 32kb allocation
- Tried the QUICK and LONG format option
- Try different MicroSD Cards SandDisk and Other local brands as well
- Try different size 32GB, 16GB, 8GB, and 512mb
- Check the MicroSD Card Module as well (It worked perfectly with my Arduino Uno and Arduino Uno R4 Minima)
I also tried it with RP2040-Zero it did not work with that for some reason

- Checked the wirings and pins


(I am using female to female cables for the connection)
Also tried it with a bread board



Code:
#include <SPI.h>
#include <SD.h>

const int CS = 10;
File myFile;
int SerialNumber = 1;


void setup() {
  Serial.begin(115200);
  Serial.println("Initializing SD card...");
  Serial.println("\n==============================================");
  Serial.print("MOSI: ");
  Serial.println(MOSI);
  Serial.print("MISO: ");
  Serial.println(MISO);
  Serial.print("SCK: ");
  Serial.println(SCK);
  Serial.print("SS or CS: ");
  Serial.println(SS);
  Serial.println("==============================================\n");

  while (!SD.begin(CS)) {
    Serial.println("SD card initialization failed!");
    delay(1000);
  }

  delay(1000);
  Serial.println("SD card initialization done.");
  
}

void loop() {
 char formattedData[50];
  int randomNumber = random(100, 1000);
  sprintf(formattedData, "%lu-%d", SerialNumber, randomNumber);
  WriteFile("/NewFile.txt", formattedData);
  SerialNumber++;
  delay(1000);
}



void WriteFile(const char *path, const char *message) {
  myFile = SD.open(path, FILE_APPEND);
  if (myFile) {
    myFile.println(message);
    myFile.close();
  } else {
    Serial.println("error opening file");
  }
}
image_2026-01-04_115634115.png
image_2026-01-04_115641357.png
Was this page helpful?