From d46d742db1c066eb36ef2d4d0706e0faba1f2c23 Mon Sep 17 00:00:00 2001 From: WereCatf Date: Sat, 29 Oct 2016 12:40:06 +0300 Subject: [PATCH] Use WIFI_STA in WiFiClient-examples Many people have problems with using ESP8266 as WiFi-client due to none of the examples mentioning that you should use WIFI_STA if you only want the ESP8266 to act as a WiFi-client. Many WiFi-devices will randomly try to connect to the ESP8266 if used as STA+AP and complain about not being able to access the Internet or other devices on the network. --- libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient.ino | 4 ++++ .../examples/WiFiClientEvents/WiFiClientEvents.ino | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient.ino b/libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient.ino index 4e3b78d5a..427e2afbd 100644 --- a/libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient.ino +++ b/libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient.ino @@ -26,6 +26,10 @@ void setup() { Serial.print("Connecting to "); Serial.println(ssid); + /* Explicitly set the ESP8266 to be a WiFi-client, otherwise, it by default, + would try to act as both a client and an access-point and could cause + network-issues with your other WiFi-devices on your WiFi-network. */ + WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { diff --git a/libraries/ESP8266WiFi/examples/WiFiClientEvents/WiFiClientEvents.ino b/libraries/ESP8266WiFi/examples/WiFiClientEvents/WiFiClientEvents.ino index bdad5be30..249e896e9 100644 --- a/libraries/ESP8266WiFi/examples/WiFiClientEvents/WiFiClientEvents.ino +++ b/libraries/ESP8266WiFi/examples/WiFiClientEvents/WiFiClientEvents.ino @@ -34,6 +34,10 @@ void setup() { WiFi.onEvent(WiFiEvent); + /* Explicitly set the ESP8266 to be a WiFi-client, otherwise, it by default, + would try to act as both a client and an access-point and could cause + network-issues with your other WiFi-devices on your WiFi-network. */ + WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); Serial.println();