     }
 }
 
+#ifdef DO_LOGGING
+
+// Restriction on filename length is 8 chars not including extension for FAT?
+// Readings_018.txt is what seems to get generated, so maybe 12 chars
+void getFilename()
+{
+  filename = FILE_DIRECTORY;
+  filename += 'R';
+  
+  filename += year();
+  filename += '_';
+  
+  if (month() < 10) {filename += '0';}
+  filename += month();
+  filename += '_';
+  
+  if (day() < 10) {filename += '0';}
+  filename += day();
+
+  filename += ".txt";
+
+  // Push to filePath char array
+  filename.toCharArray(filePath, MAX_FILEPATH_LENGTH);
+}
+
 // Store data on file : TODO Save to separate file each day
 void logToFile()
 {
-  File dataFile = FileSystem.open(FILE_PATH, FILE_APPEND);
-    if (dataFile) {    
-      dataFile.print(dateTimeString);
-      dataFile.print("\t");
-      dataFile.print(humidity[0],1);
-      dataFile.print("\t");
-      dataFile.print(temp[0],1);
-      dataFile.print("\t");
-      dataFile.print(humidity[1],1);
-      dataFile.print("\t");
-      dataFile.print(temp[1],1);
-      dataFile.print("\t");
-      dataFile.print(humidity[2],1);
-      dataFile.print("\t");
-      dataFile.print(temp[2],1);
-      dataFile.println();
-
-      dataFile.close();
-
-      Console.print("Logged: ");
-      Console.print(dateTimeString);
-      Console.print("\t");
-      Console.print(humidity[0],1);
-      Console.print("\t");
-      Console.print(temp[0],1);
-      Console.print("\t");
-      Console.print(humidity[1],1);
-      Console.print("\t");
-      Console.print(temp[1],1);
-      Console.print("\t");
-      Console.print(humidity[2],1);
-      Console.print("\t");
-      Console.print(temp[2],1);
-      Console.println();
-    }
-    else
-    {
-      Console.println("error opening logfile");
-    }
-}
+  File dataFile = FileSystem.open(filePath, FILE_APPEND);
+  datestring = "";
+  datestring += year();
+  datestring += '/';
+  if (month() < 10) {datestring += '0';}
+  datestring += month();
+  datestring += '/';
+  
+  if (day() < 10) {datestring += '0';}
+  datestring += day();
+  datestring += ' ';
+
+  if (hour() < 10) {datestring += '0';}
+  datestring += hour();
+  datestring += ':';
+
+  if (minute() < 10) {datestring += '0';}
+  datestring += minute();
+
+  if (dataFile) {    
+    dataFile.print(datestring);
+    dataFile.print("\t");
+    dataFile.print(humidity[0],1);
+    dataFile.print("\t");
+    dataFile.print(temp[0],1);
+    dataFile.print("\t");
+    dataFile.print(humidity[1],1);
+    dataFile.print("\t");
+    dataFile.print(temp[1],1);
+    dataFile.print("\t");
+    dataFile.print(humidity[2],1);
+    dataFile.print("\t");
+    dataFile.print(temp[2],1);
+    dataFile.println();
+
+    dataFile.close();
+
+    Console.print("Logged to ");
+    Console.print(filePath);
+    Console.print(": ");
+
+    Console.print(datestring);
+    Console.print("\t");
+    Console.print(humidity[0],1);
+    Console.print("\t");
+    Console.print(temp[0],1);
+    Console.print("\t");
+    Console.print(humidity[1],1);
+    Console.print("\t");
+    Console.print(temp[1],1);
+    Console.print("\t");
+    Console.print(humidity[2],1);
+    Console.print("\t");
+    Console.print(temp[2],1);
+    Console.println();
+  }
+  else
+  {
+    Console.print("Error opening ");
+    Console.println(filePath);
+
+    lcd.clear();
+    lcd.print("SD Write Error");
+    lcd.setCursor(0,1);
+    lcd.print(filePath);
+    lcd.print("SD Write Error");
+    
+    delay(2000);
+  }
+}
+#endif
 
 
 void updateLCD()


    updateLCD();
  }

  //// EVERY 10 SECONDS
  // Read sensors every 10 seconds

{
  Bridge.begin();
  Console.begin();
#ifdef DO_LOGGING
  FileSystem.begin();
  filename.reserve(MAX_FILEPATH_LENGTH);
  datestring.reserve(20);
#endif
  lcd.init();
  lcd.backlight();

