 		digitalWrite(GREENLED, LOW);
 		ESP.deepSleep(sleepinterval * 1000000);
 	}
+  }
+  //  Setup mqtt
+  if (setupMQTT() == 1){
+    // Ignore this outcome it hasn't done anything
+  } else {
+    // We have setupMQTT
+    if( mqttconnect() != 0 ){
+      // Haven't been able to connect :|
+      // Handle this exception. Probably reload?
+      Serial.println("Unable to connect to MQTT after reset");
+
+    }
   }
   dhtinit();
   dhtmeasure();

  if (!configloaded) {
    loadconfig();
  }
  int sleepinterval = 10; // seconds
  
  if ( !trySTAWiFi() ) {
    // STA Failed so load softAP

	  
  

  Serial.println("Sleep for " + sleepinterval + "s");

  digitalWrite(REDLED, LOW);
  digitalWrite(GREENLED, LOW);
