-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add separat file for wifi and improve serial output
- Loading branch information
1 parent
b891fa7
commit 3caac57
Showing
4 changed files
with
45 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,28 @@ | ||
|
||
void setupOta() { | ||
Serial.println(F("\n=== OTA")); | ||
Serial.println(F("Waiting for updates ...")); | ||
|
||
ArduinoOTA.setPort(otaPort); | ||
ArduinoOTA.setHostname(otaHostName); | ||
ArduinoOTA.setPassword(otaPassword); | ||
|
||
ArduinoOTA.onStart([]() { | ||
Serial.println("Start"); | ||
Serial.println(F("Start")); | ||
}); | ||
ArduinoOTA.onEnd([]() { | ||
Serial.println("\nEnd"); | ||
Serial.println(F("\nEnd")); | ||
}); | ||
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) { | ||
Serial.printf("Progress: %u%%\r", (progress / (total / 100))); | ||
}); | ||
ArduinoOTA.onError([](ota_error_t error) { | ||
Serial.printf("Error[%u]: ", error); | ||
if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed"); | ||
else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed"); | ||
else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed"); | ||
else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed"); | ||
else if (error == OTA_END_ERROR) Serial.println("End Failed"); | ||
if (error == OTA_AUTH_ERROR) Serial.println(F("Auth Failed")); | ||
else if (error == OTA_BEGIN_ERROR) Serial.println(F("Begin Failed")); | ||
else if (error == OTA_CONNECT_ERROR) Serial.println(F("Connect Failed")); | ||
else if (error == OTA_RECEIVE_ERROR) Serial.println(F("Receive Failed")); | ||
else if (error == OTA_END_ERROR) Serial.println(F("End Failed")); | ||
}); | ||
ArduinoOTA.begin(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
// Create an ESP8266 WiFiClient class to connect to the MQTT server. | ||
WiFiClient client; | ||
// or... use WiFiFlientSecure for SSL | ||
//WiFiClientSecure client; | ||
|
||
void setupWifi() { | ||
Serial.println(F("\n=== WiFi")); | ||
Serial.print(F("Connecting to \"")); | ||
Serial.print(wifiSsid); | ||
Serial.print(F("\"\t")); | ||
|
||
WiFi.mode(WIFI_STA); | ||
WiFi.begin(wifiSsid, wifiPassword); | ||
|
||
while (WiFi.status() != WL_CONNECTED) { | ||
delay(500); | ||
digitalWrite(led2, HIGH); | ||
delay(20); | ||
digitalWrite(led1, LOW); | ||
Serial.print(F(".")); | ||
} | ||
Serial.println(); | ||
|
||
Serial.println(F("Status\t\t\tWiFi connected!")); | ||
Serial.print(F("IP address\t\t")); | ||
Serial.println(WiFi.localIP()); | ||
} |