     Serial.println("No reply");
   }
   
-  delay(5000);
-}
+  // Watchdog will wake us up in 8 seconds time.
+  goToSleep();
+}
+
+/**
+ * Watchdog for while awake to ensure things are ticking over.
+ */
+void watchdog_setup() {
+  // Clear any previous watchdog interupt
+  MCUSR = 0;
+  
+  // Reset after 8 seconds, 
+  // unless wdt_reset(); has been successfully called
+  
+  /* In order to change WDE or the prescaler, we need to
+   * set WDCE (This will allow updates for 4 clock cycles).
+   */
+  WDTCSR |= (1<<WDCE) | (1<<WDE);
+
+  /* set new watchdog timeout prescaler value */
+  WDTCSR = 1<<WDP0 | 1<<WDP3; /* 8.0 seconds */
+  
+  /* Enable the WD interrupt (note no reset). */
+  WDTCSR |= _BV(WDIE);
+  
+  //wdt_enable(WDTO_8S);
+  wdt_reset();
+}
+
+void goToSleep() {
+  //digitalWrite(LED_DEBUG, LOW);
+  
+ 
+  cli();
+  
+  // disable ADC
+  byte old_ADCSRA = ADCSRA;
+  ADCSRA = 0;
+  
+  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
+
+  power_all_disable();  // power off ADC, Timer 0 and 1, serial interface
+  sleep_enable();
+  sei();
+  
+  // turn off brown-out enable in software
+  MCUCR = bit (BODS) | bit (BODSE);  // turn on brown-out enable select
+  MCUCR = bit (BODS);        // this must be done within 4 clock cycles of above
+  sleep_cpu();              // sleep within 3 clock cycles of above
+                              
+  sleep_disable();  
+  MCUSR = 0; // clear the reset register 
+  
+  power_all_enable();    // power everything back on
+  
+  // put ADC back
+  ADCSRA = old_ADCSRA;
+  
+  //digitalWrite(LED_DEBUG, HIGH);
+  
+} 
 
 /**
  * Read the internal voltage.

}

uint16_t readTemperature() {
  if (onewireSensors.isConversionAvailable(deviceAddress)) {
    // Send the command to get temperatures
    onewireSensors.requestTemperatures(); 
    return onewireSensors.getTempCByIndex(0);
  }
  return 99; // Indicates a bad read.
}


#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <avr/wdt.h>
#include <avr/sleep.h>    // Sleep Modes
#include <avr/power.h>    // Power management

#define RNG_WATCHDOG 0 // and remove ISR(WDT_vect) from RNG.cpp (line 195) 

#include <Crypto.h>
#include <AES.h>
#include <RH_RF95.h>
