I have a Pro Micro board and I try to make it list my files as in the example of the Arduino IDE. The pins I use are the following:

board    micro sd module
   D4  ---> CS
   D15 ---> SCK
   D14 ---> MISO
   D16 ---> MOSI
   GND ---> GND
   VCC ---> VCC

On the serial monitor I get "initiallization failed".

What is wrong with my setup?

This is the code running:

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

File root;

void setup() {
  // Open serial communications and wait for port to open:
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only

  Serial.print("Initializing SD card...");

  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    while (1);
  Serial.println("initialization done.");

  root = SD.open("/");

  printDirectory(root, 0);


void loop() {
  // nothing happens after setup finishes.

void printDirectory(File dir, int numTabs) {
  while (true) {

    File entry =  dir.openNextFile();
    if (! entry) {
      // no more files
    for (uint8_t i = 0; i < numTabs; i++) {
    if (entry.isDirectory()) {
      printDirectory(entry, numTabs + 1);
    } else {
      // files have sizes, directories do not
      Serial.println(entry.size(), DEC);

And this is my wiring: enter image description here enter image description here enter image description here

  • 1
    Please add your code. Oct 30, 2018 at 16:37
  • maybe your program consists of only these two commands ..... Serial.begin(9600); Serial.println("initiallization failed"); ..... that would give you the observed output
    – jsotola
    Oct 30, 2018 at 16:49
  • 1
    did you insert the card?
    – Juraj
    Oct 30, 2018 at 18:40
  • what are the voltages of board and SD module?
    – Juraj
    Oct 30, 2018 at 18:44
  • 2
    @MichelKeijzers, read the chat finale
    – Juraj
    Oct 31, 2018 at 13:25

2 Answers 2


The SD library works only with FAT and FAT32 format. SD.begin() reads the 'disc volumes' and opens the root folder. If the card is not formatted or formatted with other file system standard, begin() fails.

EDIT: and the pin headers must be soldered

enter image description here

  • Yea, I got it. I just formated it to FAT32 and it didnt work either. What else could it be?
    – George Sp
    Oct 31, 2018 at 9:35

Here's my setup code for my SD card for a little circuit where I was writing temperature data to the card.

const int SD_CS = 10;
   const long SLEEP_TIME = 60000;  // write to card every minute
   long multiplier = 0;

   LiquidCrystal_I2C lcd(0x3F, 20, 4);

   void setup() {

     lcd.print("Hello, LCD!");  

     if (SD.begin(SD_CS)) { // init SD 
       lcd.print("SD card init");


I set the CS pin to D10.
Try switching it to another pin like this and see if you get a different result. I believe I had a challenge when I used pin 4 but can't quite remember.

Note: And of course remember to move your CS wire to pin D10 or whichever one you use.


Not the answer you're looking for? Browse other questions tagged or ask your own question.