SD-card initialization failed

hello,

I want to save data from my sensors to a sd-card. I haven’t worked with a sd-card before so I thought lets try some code from someone else. I found a code on How to mechatronics, so I used that code…

but I con’t get it to work. Most of the time it gives the error:“initialization failed” and if it doesn’t give that error it says: “error opening test.txt Read:”

I have tried several things: new kabels, different sd-cards, updating lyberies, checking if I wired it corretly different arduino’s but non of them have worked yet.

I have to sd card holders for a normal sd-card. I only have micro sd cards so I use a adapter for micro sd to normal sd. the sd I tried are all 32GB and have FAT32 on them.

I hope someone knows what I am doing wrong.

/*
 *  Arduino SD Card Tutorial Example
 *  
 *  by Dejan Nedelkovski, www.HowToMechatronics.com
 */
#include <SD.h>
#include <SPI.h>
File myFile;
int pinCS = 53; // Pin 10 on Arduino Uno
void setup() {
    
  Serial.begin(9600);
  pinMode(pinCS, OUTPUT);
  
  // SD Card Initialization
  if (SD.begin())
  {
    Serial.println("SD card is ready to use.");
  } else
  {
    Serial.println("SD card initialization failed");
    return;
  }
  
  // Create/Open file 
  myFile = SD.open("test.txt", FILE_WRITE);
  
  // if the file opened okay, write to it:
  if (myFile) {
    Serial.println("Writing to file...");
    // Write to file
    myFile.println("Testing text 1, 2 ,3...");
    myFile.close(); // close the file
    Serial.println("Done.");
  }
  // if the file didn't open, print an error:
  else {
    Serial.println("error opening test.txt");
  }
  // Reading the file
  myFile = SD.open("test.txt");
  if (myFile) {
    Serial.println("Read:");
    // Reading the whole file
    while (myFile.available()) {
      Serial.write(myFile.read());
   }
    myFile.close();
  }
  else {
    Serial.println("error opening test.txt");
  }
  
}
void loop() {
  // empty
}

the image shows the weird files it makes

the sd I tried are all 32GB and have FAT32 on them.

This post really belongs in Storage, since it is NOT a programming issue.

I mention the correct place, because you really need to go there and read the stickies. I’ll bet that a clue-by-four whacks you before you are done reading.