Writing and reading directly from SD data logger to control Arduino output pins

Greetings,

I am trying to figure out how to write sensor readings for a specific period of time to an SD card and then open and read from that file directly on the SD data logging shield in order to control other outputs directly from the Arduino instead of reading the information on a host computer. So far I have experimented with the Adafruit light and temperature sketch and trying to add on some of the code from the “SD card read/write” sketch from the Arduino Tutorial SD Libraries Examples. The combination I have arrived at retrieve one or two time stamp readings and then throws the process out of the loop. Any suggestions of other examples would be much appreciated.

Thanks, John

lighttemplogger2.ino (6.86 KB)

  logfile = SD.open("logfile");

Interesting. In setup(), you opened a file called “LoggerXX.CSV” (where XX is replaced by two digits). You never close that file.

You write to that file on every pass through loop().

Then, you open a file called “logfile”, and expect to find data there. Why?