   tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_402MS);  /* 16-bit data but slowest conversions */
 }
 
+void sleep(long milliseconds)
+{
+   while(milliseconds > 0)
+   {
+      if(milliseconds > 8000)
+      {
+         milliseconds -= 8000;
+         Narcoleptic.delay(8000);
+      }
+      else
+      {
+        Narcoleptic.delay(milliseconds);
+        break;
+      }
+   }
+}

    Serial.print("Ooops, no TSL2561 detected ... Check your wiring or I2C ADDR!");
    while(1);
  }
  
  /* Setup the sensor gain and integration time */
  configureLightSensor();
  

}

void loop() {
  digitalWrite(LEDPIN, HIGH);
   
  Serial.print("{'_sensor': 'weather', '_sample': {'_id':"); 
  Serial.print(sample++); 

  Serial.println("}}");
  
  digitalWrite(LEDPIN, LOW);
  digitalWrite(XBEESLEEPPIN, HIGH);  //Put XBEE to sleep
  
  sleep(30000);
}

void configureLightSensor(void)
