Hi There,
I am currently using this sketch to record and log the temperature of 1 sensor attached to my uno with the Adafruit Logger shield.
#include <SD.h>
#include <Wire.h>
#include "RTClib.h"
#define ECHO_TO_SERIAL 1
RTC_DS1307 RTC;
void setup() {
Serial.begin(57600);
Wire.begin();
RTC.begin();
if (!RTC.isrunning()) {
Serial.println("RTC is NOT running!");
}
pinMode(10, OUTPUT);
SD.begin(4);
}
File myFile;
float value;
float time;
void loop() {
myFile = SD.open("test.csv", FILE_WRITE);
DateTime now = RTC.now();
if (myFile) {
value = analogRead(0) * 5 / 1024.0;
value = value - 0.5;
value = value / 0.01;
myFile.print(now.day(), DEC);
myFile.print('/');
myFile.print(now.month(), DEC);
myFile.print('/');
myFile.print(now.year(), DEC);
myFile.print(' ');
myFile.print(now.hour(), DEC);
myFile.print(':');
myFile.print(now.minute(), DEC);
myFile.print(':');
myFile.print(now.second(), DEC);
myFile.print(",");
myFile.println(value);
Serial.print(now.day(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.year(), 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.println(value);
}
myFile.close();
delay(1000);
}
when I open the data in Excel it has two nice columns; the first filled with the date and time, the second filled with the temperature readings. What would i add to the sketch to get a column heading at the top of each column when I open the CSV file in Excel???
Thanks