I have a data logging project where I post some data every 15 minutes to an SD card.
While the project was running (way before the next write) I removed the card for a minute to look at the data already written and then inserted it again. Once I remove the card and put it back it never writes to the card again. The sketch continues to run as I see the output on the serial monitor but nothing shows up on the card.
I am using the Deek-Robot shield
Is this the way it works / a known issue / or might I be missing something?
String FormattedDateTime(DateTime UnformattedDateTime)
{
String LocalFormattedDateTime = "";
if (UnformattedDateTime.month() < 10)
LocalFormattedDateTime += "0";
LocalFormattedDateTime += UnformattedDateTime.month();
LocalFormattedDateTime += '/';
if (UnformattedDateTime.day() < 10)
LocalFormattedDateTime += "0";
LocalFormattedDateTime += UnformattedDateTime.day();
LocalFormattedDateTime += '/';
LocalFormattedDateTime += UnformattedDateTime.year();
LocalFormattedDateTime += ' ';
if (UnformattedDateTime.hour() < 10)
LocalFormattedDateTime += "0";
LocalFormattedDateTime += UnformattedDateTime.hour();
LocalFormattedDateTime += ':';
if (UnformattedDateTime.minute() < 10)
LocalFormattedDateTime += "0";
LocalFormattedDateTime += UnformattedDateTime.minute();
LocalFormattedDateTime += ':';
if (UnformattedDateTime.second() < 10)
LocalFormattedDateTime += "0";
LocalFormattedDateTime += UnformattedDateTime.second();
return LocalFormattedDateTime;
} // FormattedDateTime
void WriteDataToLogFile(float Distance)
{
myFile = SD.open("test.txt", FILE_WRITE);
if (myFile) // If the file opened okay, write to it:
{
myFile.print(FormattedDateTime(RTC.now()));
myFile.print(",");
myFile.println(Distance);
myFile.close();
}
} // WriteDataToLogFile