there was a common problem with your library and all of the programs which i wrote in the past and that was problem initilizing sd card in first definition step.
if (!SD.begin(SD_CS_PIN)) {}
was randomly true.
i had tested this situation with lots of SD card modules and arduino boards. for example Mega 2560, Uno, Due.
after lots of searches i found the problem can be solved with adding a simple delay(150) to the file SdSpiCard.cpp in line 141 which is :
while (cardCommand(CMD0, 0) != R1_IDLE_STATE) {
delay(150); //Added line
if (isTimedOut(t0, SD_INIT_TIMEOUT)) {
error(SD_CARD_ERROR_CMD0);
goto fail;
}
}
this solved the whole problem. please investigate this and add the line if it's true.
there was a common problem with your library and all of the programs which i wrote in the past and that was problem initilizing sd card in first definition step.
if (!SD.begin(SD_CS_PIN)) {}
was randomly true.
i had tested this situation with lots of SD card modules and arduino boards. for example Mega 2560, Uno, Due.
after lots of searches i found the problem can be solved with adding a simple delay(150) to the file SdSpiCard.cpp in line 141 which is :
while (cardCommand(CMD0, 0) != R1_IDLE_STATE) {
delay(150); //Added line
if (isTimedOut(t0, SD_INIT_TIMEOUT)) {
error(SD_CARD_ERROR_CMD0);
goto fail;
}
}
this solved the whole problem. please investigate this and add the line if it's true.