Hello,
I'm currently working with the Arduino Due and a 16 GB Kingston microSD card in a data logging application. The application actuates some relays, takes some measurements, and then dumps those measurements to the SD card. This logger is transmitting at most 168 bytes every few seconds, though this writing is all lumped together, not spread out over the whole period. Each cycle, I run a SD.open(), use a series logfile.print() calls, and then run logfile.close().
I'm having trouble in two spots, but not consistently.
-
SD.exists() method is not always finding files. All filenames are of the format "logXXX.txt" where XXX is a number between 000 and 999. I've written a small function which loops through a number to find what is already on the card. It starts at log000.txt and checks it with SD.exists() and continues to increment until it finds a file not already created which it uses for the session. Sometimes it can find a file that is there, sometimes it can't and will start at seemingly random spots, i.e. log000.txt-log009.txt are on the card and it will pick log004.txt. This inconsistency suggests to me that there's some sort of corruption or failure to read temporarily.
-
When I check the files on the card, I sometimes find that the files I created contain garbage values. Sometimes these bytes are in between logs and sometimes they are instead of the data I logged (checked by also printing all of the data to a terminal). Additionally, sometimes there are garbage filenames (using illegal ASCII characters) and when this happens Windows flags the card as corrupted and recommends running their software to fix it. This happens much more rarely though.
I'm having trouble finding the root cause of these issues as they happen inconsistently, though I suspect they are linked. I don't believe my program is at fault due to it sometimes working for longer stretches without issue. I'm inclined to think an electrical issue. I am powering the SD card directly from the Arduino Due's 3V3 pin and I saw some posts in this forum mentioning that the SD card can pull a relatively large current during writes.
Do these symptoms sound familiar to anyone? Is there anymore information I should seek out to investigate this further?