-1

When I open a file, SD.open(...), if there is no microsd it takes 1s before telling me it gave an error. How can I set a shorter timeout? It would be for a hard runtime software that would have to continue even without the microsd running, and could not be subject to stop for 1s. I hope you can help me, Thank you.

I am expecting a solution to this problem.

Ken White
  • 123,280
  • 14
  • 225
  • 444
  • long time is usually caused by problems with the SPI bus. wrong CS pin or other device blocking the bus – Juraj Dec 04 '22 at 04:48
  • The microsd will be used in a rocket. I will never know if something can go wrong or not. So I wanted to set a timeout of 0 regardless of what the communication problem is. – Albino Almeida Dec 04 '22 at 11:18

1 Answers1

1

You can see if the SD card is available by using exists() for a specific file:

void loop()
{
    if (SD.exists("testfile.dat"))
        Serial.println("File exists so SD is available");
    else
        Serial.println("File does NOT exist or SD is unavailable");

   delay(1000);
}
mmixLinus
  • 1,646
  • 2
  • 11
  • 16