-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwifi.ino
More file actions
31 lines (26 loc) · 878 Bytes
/
wifi.ino
File metadata and controls
31 lines (26 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
void setup_wifi() {
delay(10);
// We start by connecting to a WiFi network
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
// Add support for OTA***************************************
ArduinoOTA.onError([](ota_error_t error) {
ESP.restart();
});
ArduinoOTA.setHostname(client_id);
// No authentication by default
ArduinoOTA.setPassword(ota_pass); //password defined in secret credentials file (also see 1Password)
ArduinoOTA.begin(); /* setup the OTA server */
// **********************************************************
}