 
 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..."));

#include "MPL3115A2.h" //Pressure sensor
#include "HTU21D.h" //Humidity sensor
#include "OneWire.h" // Water temperature sensor

#include "FreqCount.h"

#define SEND_INTERVAL 30 // Interval between consecutive data sends (in seconds)

// Defines to enable or disable sensors
#define HUMIDITY_SENSOR 1

#define EC_SENSOR 1
#define WATER_TEMPERATURE_SENSOR 1

// Define to enable or disable watchdog
#define WATCHDOG_ENABLE 0

// Constants
// Digital I/O pins
const byte FONA_KEY = 10;
