You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 25, 2019. It is now read-only.
This is not bug. You only need to initialise Sd library once. You can then make checks with File myfile = SD.open("file") that shall return file or 0 if not working. You can check if (myfile) then do work.
this is definitely a bug, in fact, if you have more than one SPI device you must call begin() each time you need to switch from another device to the SD card.
I have had the problem myself.
Solution:
in the file named SD.cpp, in function begin() (line 337) add this instruction before the return statement: if(root.isOpen()) root.close();
Demo code:
include <SD.h>
void setup()
{
Serial.begin(115200);
Serial.println("Starting...");
if (!SD.begin(53,2,4,3)) { // chipSel, mosi, miso, sck
Serial.println(F("initialization failed!"));
} else {
Serial.println(F("initialization done."));
}
if (!SD.begin(53,2,4,3)) { // chipSel, mosi, miso, sck
Serial.println(F("initialization failed!"));
} else {
Serial.println(F("initialization done."));
}
}
void loop(void) {
}
Output:
Starting...
initialization done.
initialization failed!
Expected output:
Starting...
initialization done.
initialization done.
The text was updated successfully, but these errors were encountered: