 
   sample += 1;
 
-  if (!pingCoordinator()){          //check if xbee woke up and got its association address. blink LED rapidly and quit loop otherwise
-    blink(10);
-    digitalWrite(LEDPIN, LOW);
-    digitalWrite(XBEESLEEPPIN, LOW);  //Wake UP XBEE
-    sleep(60000); 
-    return;
-  }
-
-  Serial.print("{\"_sensor\": \"weather\", \"_sample\": {\"_id\":"); 
-  Serial.print(sample); 
-  Serial.print(", "); 
-  
-  Serial.print("\"Temp\":"); printValue(dht.getTemperature());
-  Serial.print("\"RH\":"); printValue(dht.getHumidity());
-  
-  sensors_event_t event;
-  bmp.getEvent(&event); 
-  Serial.print("\"AtmoPressure\":"); printValue(event.pressure);
-  
-  uint16_t broadband = 0;
-  uint16_t infrared = 0;
- 
-  tsl.getEvent(&event); 
-  long lx = event.light;
-  tsl.getLuminosity (&broadband, &infrared);
-  if (lx == 0 && broadband > 65000){ //Sensor appears to be in direct sunlight outside it's resolution limits. Set lx value to max to simplify downstream logic
-      lx = 0xFFFF;
-  }
-  Serial.print("\"AmbientLight\":"); printValue(lx);
-  Serial.print("\"BroadbandLight\":"); printValue((long)broadband);
-  Serial.print("\"Infrared\":"); printValue((long)infrared, 0);
-
-  Serial.println("}}");
-  
-  delay(2000);   //Delay at the end to allow xbee to flush its send buffer 
+  if (!pingDestination()){          //check if xbee woke up and got its association address. blink LED rapidly and quit loop otherwise
+    blink(50, 100);
+  } else {                          //connected to the destination
+    
+    Serial.print("{\"__device\": \"weather\", \"__sample\": {\"__id\":"); 
+    Serial.print(sample); 
+    Serial.print(", "); 
+    
+    Serial.print("\"Temp\":"); printValue(dht.getTemperature());
+    Serial.print("\"RH\":"); printValue(dht.getHumidity());
+    
+    sensors_event_t event;
+    bmp.getEvent(&event); 
+    Serial.print("\"AtmoPressure\":"); printValue(event.pressure);
+    
+    uint16_t broadband = 0;
+    uint16_t infrared = 0;
+   
+    tsl.getEvent(&event); 
+    long lx = event.light;
+    tsl.getLuminosity (&broadband, &infrared);
+    if (lx == 0 && broadband > 65000){ //Sensor appears to be in direct sunlight outside it's resolution limits. Set lx value to max to simplify downstream logic
+        lx = 0xFFFF;
+    }
+    Serial.print("\"AmbientLight\":"); printValue(lx);
+    Serial.print("\"BroadbandLight\":"); printValue((long)broadband);
+    Serial.print("\"Infrared\":"); printValue((long)infrared, 0);
+  
+    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);
+  sleep(150000);
 }
 
 void printValue(float value){

  }
  else
  {
    Serial.print("'NaN'");
  }
  
  if (separator){

  }
}

int pingDestination(void){
    
    for(int i = 0; i<5; i++){
      blink(i+1);
      while(getCh() != NULL) ;       //Drain any pending chars on the serial.
      Serial.println("@PING");
      int c=0;
      while(Serial.available()<2 && c++<10){
          delay(200);
          blink(2, 50);
      }
      if (getCh()=='O' && getCh()=='K'){
