Troubles writing (too large?) header to .csv-file

Hello Arduino forum

I am working on a data logger to save movement information from an LSM9DS0 to a microSD card including time data. I want a header that would provide names for the columns I was creating in order to recognize the data and easily create charts in Excel.

I can successfully log all the desired LSM9DS0 data to the microSD card without header. But if I add a header code to the sketch it becomes impossible to write a log file. Something must go wrong here. See the attached files.

Is the amount of information in the header already too much for the Arduino Uno to handle? I cannot see an error in the code.

Equipment:

  • Arduino Uno (ATMEGA328P)
  • Adafruit LSM9DS0
  • Adafruit Micro SD Card Breakout Board
  • Adafruit DS1307 Real Time Clock Breakout Board
  • microSDHC, 32Gb, class 10 memory card

In a further project step I would love to add GSP data to the .csv file. Do you think this is possible with the storage limitations of an Arduino Uno to log GPRMC and GPGGA?

Thank you and a happy 2015.

SD-Logging_5_RTC_leading_zero_new_SD-File_header.ino (8.59 KB)

Try using the F macro on your prints to save some RAM. e.g.:

    Serial.print(F("Date"));

It may well work on your dataFile.print statements too.

Works. Thank you wildbill for the F() macro info!

Here is my working header sketch:

//_________________________Write Log File Header_________________
File dataFile = SD.open(filename, FILE_WRITE); 
  if (dataFile)
  {                                 //Use the F() macro to save RAM, http://www.baldengineer.com/arduino-f-macro.html
    dataFile.print(F("Date"));
    dataFile.print(",");
    dataFile.print(F("Time"));
    dataFile.print(",");
    dataFile.print(F("g x"));          //g-acceleration in x dircetion
    dataFile.print(",");
    dataFile.print(F("g y"));
    dataFile.print(",");
    dataFile.print(F("g z"));
    dataFile.print(",");
    dataFile.print(F("oriroll [deg]"));
    dataFile.print(",");
    dataFile.print(F("pitch [deg]"));
    dataFile.print(",");
    dataFile.print(F("head [deg]"));
    dataFile.print(",");
    dataFile.print(F("gyro.x [deg/s]"));
    dataFile.print(",");
    dataFile.print(F("y [deg/s]"));
    dataFile.print(",");
    dataFile.print(F("z [deg/s]"));
    dataFile.print(",");
    dataFile.print(F("magn.x [gauss]"));
    dataFile.print(",");
    dataFile.print(F("y [gauss]"));
    dataFile.print(",");
    dataFile.println(F("z [gauss]"));
    dataFile.close();
    Serial.print(F("Date"));
    Serial.print(",");
    Serial.print(F("Time"));
    Serial.print(",");
    Serial.print(F("g x [m/s^2]"));
    Serial.print(",");
    Serial.print(F("g y [m/s^2]"));
    Serial.print(",");
    Serial.print(F("g z [m/s^2]"));
    Serial.print(",");
    Serial.print(F("oriroll [deg]"));
    Serial.print(",");
    Serial.print(F("pitch [deg]"));
    Serial.print(",");
    Serial.print(F("head [deg]"));
    Serial.print(",");
    Serial.print(F("gyro.x [deg/s]"));
    Serial.print(",");
    Serial.print(F("y [deg/s]"));
    Serial.print(",");
    Serial.print(F("z [deg/s]"));
    Serial.print(",");
    Serial.print(F("magnetic.x [gauss]"));
    Serial.print(",");
    Serial.print(F("y [gauss]"));
    Serial.print(",");
    Serial.println(F("z [gauss]"));
  }