3 // Connect to WiFi network @home: TP
4 // const char* ssid = "ssid";
5 // const char* password = "pass";
8 Serial.print("Connecting to ");
11 WiFi.begin(ssid, password);
13 while (WiFi.status() != WL_CONNECTED) {
18 Serial.println("WiFi connected");
21 // Print the IP address
22 Serial.print("Local IP: \t");
23 Serial.println(WiFi.localIP());
24 Serial.print("Web URL: \thttp://");
25 Serial.print(WiFi.localIP());
30 // MQTT: Loop until we're reconnected
31 while (!client.connected()) {
32 Serial.println("Attempting MQTT connection...");
34 if (client.connect("ESP8266Client")) {
35 Serial.println(">> Connected <<");
36 client.subscribe(input);
38 Serial.print("failed, rc=");
39 Serial.print(client.state());
40 Serial.println(" try again in 5 seconds");
41 // Wait 5 seconds before retrying
43 // Some LED status feedback would be useful