   
     unsigned long currentMillis = millis();
   
-    if(currentMillis - previousMillis >= logInterval * 1000 && logData) {
+    if (currentMillis - previousMillis >= logInterval * 1000 && logData) {
         previousMillis = currentMillis;
       
         readDHT11();
+    }
+    
+    if (travelTimeSet && currentMillis - previousLogMillis >= logDelay) {
+        setLogInterval();
     }
 }
 

    return EEPROM.read(address);
}

void setup() {
    if (EEPROM.read(0)) logInterval = (long) EEPROM.read(0);
    if (EEPROM.read(1)) logData = (boolean) EEPROM.read(1);
    
    // Initialize pins
    pinMode(ledPin, OUTPUT);


// Variables to use for the interval
unsigned long previousMillis = 0;
unsigned long previousLogMillis = 0;
unsigned long logDelay = 0;                       // Log delay in milliseconds
int logInterval = 0;                             // Log interval in milliseconds

// Variables
dht11 DHT11;
EDB db(&writer, &reader);
long travelTime; // Total travel time in s
boolean travelTimeSet = false;
int maxLogs = 252;
String msg;
boolean logData = false;
