Anonymous
Anonymous

Reputation: 1

Arduino uno SD Card storage problems

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:

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.
}

Upvotes: 0

Views: 1256

Answers (3)

tabision
tabision

Reputation: 1

I used to use SD Sandisk 32Gb, and it worked properly with Arduino Uno. But now I change to ESP32, then it can not work nevertheless I change code, change library so many time to hope it'll work again. I'm wondering there is some issue related with SD interface with ESP32 with recently version. Waiting for new rev.

Upvotes: 0

Asder Knaster
Asder Knaster

Reputation: 104

According to the Arduino reference, only SDHC Cards are supported. SDHC cards are, by definition, limited to 32GB capacity. I would suggest trying your code with a lower capacity card. However you could also create a single partition on the SD card that only has 32GB or less. It is important, that you format this partition either in FAT16 or FAT32, as this are the only filesystems supported by the Arduino SD library.

Upvotes: 0

takeo7
takeo7

Reputation: 1

Is your SD module CS pin, connected on the digital Pin 4 of the Arduino UNO? The module does have 6 pins and you describe only 5.

After some searches I also found that a majority of SD SPI Modules don't support more than 16GB.

You should check this website, it may be useful for you : https://create.arduino.cc/projecthub/electropeak/sd-card-module-with-arduino-how-to-read-write-data-37f390

Hoping that will help.

Upvotes: 0

Related Questions