   //Local intialization. Once its business is done, there is no need to keep it around
   WiFiManager wifiManager;
 
+  if (drd.detectDoubleReset()) {
+    Serial.println("Double Reset Detected");
+    //shall do clean up of API key after wifi reset
+      wifiManager.resetSettings();
+      ESP.reset();
+      delay(1000);
+  } else {
+    Serial.println("No Double Reset Detected");
+  }
+
   //set config save notify callback
   wifiManager.setSaveConfigCallback(saveConfigCallback);
 

  //  eventCounter ++;
  //  saveCounter(eventCounter);         // this also puts bme0 to sleep
  bme0.updateF4Control16xSleep(); // use instead of saveCounter if counter is not required
  goToSleep();
} // end of void setup()


WiFiClient client; //client
String readString;

// Number of seconds after reset during which a 
// subseqent reset will be considered a double reset.
#define DRD_TIMEOUT 10

// RTC Memory Address for the DoubleResetDetector to use
#define DRD_ADDRESS 0

DoubleResetDetector drd(DRD_TIMEOUT, DRD_ADDRESS);

//callback notifying us of the need to save config
void saveConfigCallback () {
  Serial.println("Should save config");
