 
 void sleep(uint8_t sleepTime) {
 
-  while(watchdog_counter++ < sleepTime) {
+  do {
     set_sleep_mode(SLEEP_MODE_PWR_DOWN);             // select the watchdog timer mode
     sleep_enable();                                  // enable the sleep mode ready for use
     sleep_mode();                                    // trigger the sleep
     sleep_disable();                                 // prevent further sleeps 
-  }
-  watchdog_counter = 0;
+  } while(watchdogCounter < sleepTime);
+  
+  watchdogCounter = 0;
 
 }
 
 ISR(WDT_vect) {
-  watchdog_counter++;
+  watchdogCounter++;
 }
 
 

#define network 210      // RF12 Network group
#define freq RF12_433MHZ // Frequency of RFM12B module

#define USE_ACK           // Enable ACKs, comment out to disable
#define RETRY_PERIOD 5    // How soon to retry (in seconds) if ACK didn't come in
#define RETRY_LIMIT 5     // Maximum number of times to retry
#define ACK_TIME 10       // Number of milliseconds to wait for an ack

//--------------------------------------------------------------------------------------------------
// Sleep Configuration 
//-------------------------------------------------------------------------------------------------
// 0=16ms, 1=32ms,2=64ms,3=128ms,4=250ms,5=500ms,6=1 sec,7=2 sec, 8=4 sec, 9=8 sec
void setup_watchdog(uint8_t sleepMode) {

  byte sleepByte;
  if (sleepMode > 9 ) sleepMode = 9;
  sleepByte = sleepMode & 0x07;
  if (sleepMode > 7) sleepByte |= (1<<5);
  sleepByte |= (1<<WDCE);

