'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:
- SCK -> PIN 13
- MOSI -> PIN 11
- MISO -> PIN 12
- 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.
}
Solution 1:[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.
Solution 2:[2]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Asder Knaster |