 
     updateLCD();
   }
+
+  //// EVERY DAY (Update Filename here before writing etc.)
+  if (day() != last_day)
+  {
+    last_day = day();
+#ifdef DO_LOGGING
+    getFilename();
+    Console.print("Filename set to: ");
+    Console.println(filePath);
+
+    lcd.clear();
+    lcd.print("Filename set to:");
+    lcd.setCursor(0, 1);
+    lcd.print(filename.substring(8)); // Assuming 8 chars is length of FILE_DIRECTORY
+    delay(2000);
+#endif
+  }
+
 
   //// EVERY 10 SECONDS
   // Read sensors every 10 seconds


dht DHT;

//#define DO_LOGGING
#define FILE_PATH ("/mnt/sd/datalog.txt")

// Pins 2/3 are hardwired for I2C on the Arduino Yun
#define DHT22_PIN 4

    }
}

#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(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()
