 void setup() {
   pinMode( LEDPIN , OUTPUT);
   pinMode( XBEESLEEPPIN , OUTPUT);
-  
+
+/* digitalWrite(XBEESLEEPPIN, LOW);  //Wake UP XBEE
+*/
+
   Serial.begin(57600); 
   dht.setup(DHTPIN);
   

    Serial.print("Ooops, no TSL2561 detected ... Check your wiring or I2C ADDR!");
    while(1);
  }
}

void loop() {
  digitalWrite(LEDPIN, HIGH);
  digitalWrite(XBEESLEEPPIN, LOW);  //Wake UP XBEE

  configureLightSensor();
   
  Serial.print("{'_sensor': 'weather', '_sample': {'_id':"); 
  Serial.print(sample++); 
  Serial.print(", "); 
  
  float h = dht.getHumidity();

  }
  Serial.println("}}");
  
  delay(2000);   //Delay at the end to allow xbee to flush its send buffer 

  digitalWrite(LEDPIN, LOW);
  digitalWrite(XBEESLEEPPIN, HIGH);  //Put XBEE to sleep
  
  sleep(60000);
}


int pingCoordinator(void){
    
    for(int i = 0; i<10; i++){
      blink(i);
      while(getCh() != NULL) ;       //Drain any pending chars on the serial.
      Serial.println("@PING");
      int c=0;
      while(Serial.available()<2 && c++<10){
          delay(400);
          blink(2, 50);
      }
      if (getCh()=='O' && getCh()=='K'){
          //while(getCh() != NULL) ;       //Drain any pending messages on the serial.
          return 1;
      }
      delay(500);
    }
    return 0;
}
/*
    Wake up the XBEE from sleep. 
    For hibernation periods longer than 10sec, or so, XBee will have to re-join the PAN. 
    Use ATMY command to confirm that the node got its network address before attempting to send data to DH/DL 
*/
/*
int wakeUpXbee(void){
    while(getCh() != NULL) ;       //Drain any pending messages on the serial.
    
    Serial.print("+++");
    delay(500);
    if (getCh()=='O' && getCh()=='K'){
        for(int j=0; j<5; j++){
          Serial.println("ATMY");
          if (!(getCh()=='F' && getCh()=='F' && getCh()=='F' & getCh()=='E')){
             Serial.println("ATCN");  //Got non-FFFE address. Exit command mode immediately.
             return 1;
          }
          delay(1000);
        }
    }
  return 0;
}
*/

char getCh(){
  if (Serial.available()){
    return Serial.read();
  }
  return NULL;
}

void configureLightSensor(void)
