Micro SD-CARD Reader wont initialize on Arduino MEGA-2560

Hey I have a problem.
Im doing a school project with the Arduino mega 2560 and a Micro-SD card reader (the Reader: MissBirdler B01N40RKIL The SD-Card Reader)

Also i am using a 64 GB Micro-SD card formatted to FAT-32. Its a Samsung 64GB EVO PLUS Micro-SDXC U3.

My pin Layout is like this: SPI: 50 (MISO), 51 (MOSI), 52 (SCK), 53 (CS). VCC and Ground is self explanatory.

My Error Message is this: Initializing SD-Card… Initialization failed

I used this example Programm for testing:

/////////////////////////////////////////////////////////////////
// Arduino SD Card Tutorial v1.00 //
// Get the latest version of the code here: //
// http://educ8s.tv/arduino-sd-card-tutorial //
/////////////////////////////////////////////////////////////////
#include <SD.h>
#include <SPI.h>

int CS_PIN = 53;

File file;

void setup()
{

Serial.begin(9600);

initializeSD();
createFile(“test.txt”);
writeToFile(“This is sample text!”);
closeFile();

openFile(“prefs.txt”);
Serial.println(readLine());
Serial.println(readLine());
closeFile();
}

void loop()
{
}

void initializeSD()
{
Serial.println(“Initializing SD card…”);
pinMode(CS_PIN, OUTPUT);

if (SD.begin())
{
Serial.println(“SD card is ready to use.”);
} else
{
Serial.println(“SD card initialization failed”);
return;
}
}

int createFile(char filename)
{
file = SD.open(filename, FILE_WRITE);

if (file)
{
Serial.println(“File created successfully.”);
return 1;
} else
{
Serial.println(“Error while creating file.”);
return 0;
}
}

int writeToFile(char text)
{
if (file)
{
file.println(text);
Serial.println("Writing to file: ");
Serial.println(text);
return 1;
} else
{
Serial.println(“Couldn’t write to file”);
return 0;
}
}

void closeFile()
{
if (file)
{
file.close();
Serial.println(“File closed”);
}
}

int openFile(char filename)
{
file = SD.open(filename);
if (file)
{
Serial.println(“File opened with success!”);
return 1;
} else
{
Serial.println(“Error opening file…”);
return 0;
}
}

String readLine()
{
String received = “”;
char ch;
while (file.available())
{
ch = file.read();
if (ch == ‘\n’)
{
return String(received);
}
else
{
received += ch;
}
}
return “”;
}

Unless things have changed, the SD.h library doesn't support SDXC cards. There may be an Adafruit library that does, or you might try this one:

I don't know whether U3 messes things up.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.