 
   // Connection to the SIM800
   Serial2.begin(4800);
+
+#if WATCHDOG_ENABLE
+  cli(); // Disable interrupts
+
+  wdt_reset();
+
+  // Enable modifications to the watchdog
+  WDTCSR |= (1<<WDCE) | (1<<WDE);
+
+  // Set new watchdog timeout (8 seconds) and set watchdog to interrupt mode 
+  WDTCSR = (1<<WDP3) | (1<<WDP0) | (1<<WDIE);
+
+  wdt_cycles = 0;
+  wdt_reset();
+
+  sei(); // Enable interrupts
+#endif // WATCHDOG_ENABLE
 
   calc_sensors();
 }


    disable_fona();
  }
  
  // Increase counter, sleep for 1 second.
  time_elapsed++;
  delay(1000);


Adafruit_FONA fona = Adafruit_FONA(FONA_RST);

#if WATCHDOG_ENABLE
uint8_t wdt_cycles;

// Watchdog timer interrupt
ISR(WDT_vect) {
  // More than 1 minute without finishing the loop, something might have happened
  if (wdt_cycles >= 8) {
    // Enable modifications to the watchdog
    WDTCSR |= (1<<WDCE) | (1<<WDE);
    // Set new watchdog timeout (8 seconds) and set watchdog to interrupt and
    // system reset mode
    WDTCSR = (1<<WDP3) | (1<<WDP0) | (1<<WDIE) | (1<<WDE);
  }
  wdt_cycles++;
}
#endif // WATCHDOG_ENABLE


void setup() {
  Serial.begin(115200);
  Serial.println(F("Initializing..."));
