 
     pinMode(RED_LED_PIN, OUTPUT);
     pinMode(GREEN_LED_PIN, OUTPUT);
+
+    //Using an external voltage reference for increased accuracy
+    analogReference(EXTERNAL);
+    analogRead(0); //To help settle the ADC before taking readings
+
+    // WDT setup
+    cli(); //disable interrupts
+    wdt_reset();
+    // Enter 'Config mode'
+    WDTCSR |= (1<<WDCE) | (1<<WDE);
+
+    // Set interupts, reset on timeout, last 4 do time (1001 is 8sec)
+    WDTCSR = (1<<WDIE) | (0<<WDE) | (1<<WDP3) | (0<<WDP2) | (0<<WDP1) | (1<<WDP0);
+
+    sei(); //enable interupts
+  
 
 #if !(TEST)
     // initialize the SD card

#include <Wire.h>
#include "RTClib.h"
#include <avr/sleep.h> //for sleeping
#include <avr/wdt.h> //for waking up

#define AREF_VOLT 4.096 //Using an external voltage reference (LM4040)
#define TEST 1 //Used during testing to enable/disable certain functionality
#define NAME_LENGTH 25 // Length of the filenames

void loop() {
    // TO DO
    test();

    if(WDT_FLAG == TRUE){
        WDT_FLAG = FALSE;
    }
}
