       // trigger timer before we try again
       //startWifiConnectTimer();
 
-      // Sleep for 1 minute
-      ESP.deepSleep(60000000);
+      // Serial.println("Simulating deep sleep, couldn't find known network");
+      // delay(5000);
+      // ESP.restart();
+      // Serial.println("Shouldn't have gotten here");
+
+      // Sleep for 5 minute
+      Serial.println("startWiFi:Deep sleeping (couldn't find known network)");
+      ESP.deepSleep(300000000);
 
     }
   } else {
     // We are connected to a network
     // Only if we were waiting for wifi do these
     // otherwise just carry on
-    if (isWaitingForWiFi == true) {
-      isWaitingForWiFi = false;
-      configureOTA();
-      //startSensorTimer();
-
-    }
+    // if (isWaitingForWiFi == true) {
+    //   isWaitingForWiFi = false;
+    //   configureOTA();
+    //   //startSensorTimer();
+    //
+    // }
   }
 }
 

        // trigger timer before we try again
        //startWifiConnectTimer();

        // Sleep for 1 minute
        ESP.deepSleep(60000000);
      }
    } else {
      // Couldn't find a known network to connect to


 Serial.println(callBackDetails);
}

void publishDebug(String debugMessage) {
  Serial.println("Publishing debug message="+debugMessage);
  String payload = "{\"d\":{\"myName\":\"ESP8266.Test1\",\"message\":";

  payload += "\""+debugMessage+"\"}}";

  Serial.println("debugMessage payload = "+payload);
  if (client.publish(debugTopic, (char *) payload.c_str())) {
    Serial.println("Published debug OK");
  } else {
    Serial.print("Publish failed with error:");
    Serial.println(client.state());
  }
}
