Hello everyone,
As you can read in the title, my sparkfun level shifting micro sd breakout doesn't write to files on the SD card. I'm using the following components:
-Arduino pro mini 3.3v ATMega328P
-Sparkfun Level shifting micro sd breakout
-Kingston 16GB micro sdhc cards
The arduino and breakout are hooked up to each other as seen in this fritzing schematic:
The breakout board does make new files, but won't write to them.
Cardinfo give the following serial data:
Initializing SD card...Wiring is correct and a card is present.
Card type: SDHC
Volume type is FAT32
Volume size (bytes): 2696937472
Volume size (Kbytes): 2633728
Volume size (Mbytes): 2572
Files found on the card (name, date and size in bytes):
SYSTEM~1/ 2017-12-01 17:25:32
INDEXE~1 2017-12-01 17:25:32 76
TEST.TXT 2000-01-01 01:00:00 0
I wrote a dummy code to demonstrate what happens, as i cannot give you the full code of my boss's project:
#include <SD.h>
#include <SPI.h>
File myFile;
const int chipSelect = 8;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
if (!SD.begin(chipSelect)){
Serial.println("SD.begin failed!");
return;
}
if (!SD.open("TEST.TXT", FILE_WRITE)){
Serial.println("SD file problem!");
myFile.close();
}
else {
myFile.close();
}
}
void loop() {
// put your main code here, to run repeatedly:
if(SD.open("TEST.TXT", FILE_WRITE)){
myFile.write("Test"); myFile.write("\r\n");
myFile.write("1, 2, 3"); myFile.write("\r\n");
myFile.close();
}
else{
Serial.println("SD file problem 2!");
}
delay(200);
}
This code returns "SD file problem 2!", which indicates that writing to the file isn't possible for some reason.
Why does it not write, and how can i solve that?
Thank you all in advance!