how to check if SD card is full?


I'm working on a project where I continuously write data to an SD card. But I want it to stop once the SD card gets full. How can I check if the SD card is full?

Thank you!

In view of the deafening silence on this, it might be better to do a short test to see how many operations take how much memory.

The current version of SdFat has a function to scan the FAT and return the number of free clusters.

Here is how it is used in the SdInfo example.

  cout << F("freeClusters: ");
  uint32_t volFree = sd.vol()->freeClusterCount();
  cout <<  volFree << endl;
  float fs = 0.000512*volFree*sd.vol()->blocksPerCluster();
  cout << F("freeSpace: ") << fs << F(" MB (MB = 1,000,000 bytes)\n");

This function is not available in the old version of SdFat used in the SD.h wrapper.

The function can take several seconds on a large SD card.

In the future I plan to maintain a free count after the first call to freeClusterCount(). Then only a few microseconds will be required after the first call.

Hi all.
I'm experimenting some developments with esp8266 and Arduino ide since few months ago.
I am very interested to add this method to check sd free space and I will be very grateful to everyone can help me.
I tried to write a sketch starting from ones found here but cannot be compiled for esp 8266.
Can you help me?