 const int  MKR1000_PINPIR1 = 14;               // choose the input pin (for PIR sensor)
 
 
+
+int calibrationTime = 30;       //the time we give the sensor to calibrate (10-60 secs according to the datasheet)
 int val = 0;                    // variable for reading the pin status
 long unsigned int lowIn;         //the time when the sensor outputs a low impulse
 long unsigned int pause = 5000;  //the amount of milliseconds the sensor has to be low before we assume all motion has stopped

           Serial.print("motion ended at ");      //output
           Serial.print(duration);
           Serial.println(" sec");    
           
          azureHttpPost("{deviceId:NeshMKR100Dev1, motion:0,elapsed:"+ duration + "}");  
    }
  }

   pinMode(MKR1000_LED, OUTPUT);

   pinMode(MKR1000_PINPIR1, INPUT);     // declare sensor as input

    
  //give the sensor some time to calibrate
  delay(50);
  Serial.print("calibrating sensor ");
    for(int i = 0; i < calibrationTime; i++){
      Serial.print(".");
      delay(1000);
      }
    Serial.println(" done");
    Serial.println("SENSOR ACTIVE");
    delay(50);

    Serial.print("check for the presence of the shield");
  //check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    // don't continue:
    while (true);
  }
   Serial.print("Good. this board supports Wifi!");

  // attempt to connect to Wifi network:
  while (status != WL_CONNECTED) {
