   while (WiFi.status() != WL_CONNECTED) {
     delay(500);
     Serial.print(".");
-    if (tries > 10) return false;
-    tries ++;
+    tries++;
+    if (tries > 25 ) return false;
   }
   Serial.println("");
   Serial.println("WiFi connected");

}

void logData(String params) {
   String url = "/rt/home.xq?_action=store&_id=";
   url += stream_id;
   url += "&_pk=";
   url += stream_pk;
   url += "&";
   url += params;
   httpGet(host,url); 
}

void blink(int n, int onms,int offms) {

String stream_id;
String stream_pk;
char* host ="kitwallace.co.uk";
char* path ="/rt/home.xq?";

// interaction
const int CONFIG = D7;
const int LED = D4;

WiFiServer server(80);
WiFiClient client;

void setup() {

  Serial.begin(9600);
    delay(1000);
  Serial.println();
  Serial.println(String("ap started: ") + ap_started + " WiFi connected: " + wifi_connected); 

  pinMode(CONFIG,INPUT);
  pinMode(LED,OUTPUT);
  digitalWrite(LED,HIGH);  // turn it off
  bool result = SPIFFS.begin();
  boolean loadOK;
  loadOK = getConfiguration();
  if (loadOK) {
     Serial.println("Configuration loaded");
     wifi_connected = connectWiFi();
  }
  else {
     Serial.println("No configuration found");
     wifi_connected = false;
  }
}

void loop() {
  if (! ap_started && (digitalRead(CONFIG) || ! wifi_connected)) {
    startAP();
    startServer();
    ap_started = true;
