Hey so I have the code and everything finished for my project the issue is my datalogger writes into the CSV. file as the time stamp and then returns the line under it as the data collected for that time. This makes it very hard to export the data to excel. How do I send the time stamp to a 2nd column so it correlates to the corresponding data point? TIA
void initializeCard(void)
{
Serial.print(F("Initializing SD card..."));
// Is there even a card?
if (!digitalRead(cardDetect))
{
Serial.println(F("No card detected. Waiting for card."));
while (!digitalRead(cardDetect));
delay(250); // 'Debounce insertion'
}
// Card seems to exist. begin() returns failure
// even if it worked if it's not the first call.
if (!SD.begin(chipSelect) && !alreadyBegan) // begin uses half-speed...
{
Serial.println(F("Initialization failed!"));
initializeCard(); // Possible infinite retry loop is as valid as anything
}
else
{
alreadyBegan = true;
}
Serial.println(F("Initialization done."));
Serial.print(fileEC);
if (SD.exists(fileEC))
{
Serial.println(F(" exists."));
}
else
{
Serial.println(F(" doesn't exist."));
}
Serial.print(fileDO);
if (SD.exists(fileDO))
{
Serial.println(F(" exists."));
}
else
{
Serial.println(F(" doesn't exist. "));
}
Serial.print(fileTEMP);
if (SD.exists(fileTEMP))
{
Serial.println(F(" exists."));
}
else
{
Serial.println(F(" doesn't exist."));
}
Serial.println(F(" CARD INITIALIZATION DONE "));
}
void tim()
{
DateTime now = rtc.now(); //get the current date-time
uint32_t ts = now.getEpoch();
// if (old_ts == 0 || old_ts != ts) {
// old_ts = ts;
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.date(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.print(' ');
Serial.print(weekDay[now.dayOfWeek()]);
Serial.println();
fd.print(now.year(), DEC);
fd.print('/');
fd.print(now.month(), DEC);
fd.print('/');
fd.print(now.date(), DEC);
fd.print(' ');
fd.print(now.hour(), DEC);
fd.print(':');
fd.print(now.minute(), DEC);
fd.print(':');
fd.print(now.second(), DEC);
fd.print(' ');
fd.print(weekDay[now.dayOfWeek()]);
fd.println();
}