Arduino uno SD Card storage problems

Hello,

I am not able to format my SD card SanDisk ultra 64GB for unknown reasons.

Regardless, I have the SD card module and arduino uno setup as follows:

SCK PIN 13
MOSI PIN11
MISO PIN12
VCC -> Vin
GND-> GND

This is my code which runs initialization done but does not return true if the file exists and I can't open my file either in SD card:

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

File myFile;

void setup() {

  Serial.begin(9600);
  while (!Serial){
  ;
  }
  Serial.print("Initializing SD card...");
  if (!SD.begin(4)) {
    //Serial.println("initialization failed!");
    ;
  }

  Serial.println("initialization done.");
  File myFile = SD.open("example.txt", FILE_WRITE);
  myFile.print("hello");
  Serial.println("hello");
  myFile.close();
  if(SD.exists("example.txt")){
    //while(myFile.available()){
    Serial.println("file exists");
    //}
    }
    else{
      Serial.println("no file found..");
      }

  //Serial.print(myFile.read());
  
}

void loop() {

  // nothing happens after setup finishes.
}

Any help is appreciated. Thank you.

Have you tried a lower capacity SD card? I though i read that the SD library didn't support cards bigger than 32Gb.

Haven't tried that yet.

Is not formatting SD card a reason behind it?

The card does have to be formatted on a desktop pc. There's a sticky at the top of this section of the board about formatting.

1 Like

where is it again? couldn't find it

You can have a look at the SDFat library as well; it does support bigger cards (not sure of the limit). I've noticed that the SD library reports the size incorrectly for cards over 4GB, something that was solved with the SDFat library.

Does not seem to work unfortunately.

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