Skip to main content
added 326 characters in body
Source Link
Juraj
  • 18.3k
  • 4
  • 32
  • 50

The esp8266 SDK libraries starts the STA connection, but it is handled by other thread then the Arduino sketch. You can wait for this connection in setup with waitForConnectResult. It returns status().

 if (WiFi.waitForConnectResult() != WL_CONNECTED) { Serial.println("Not connected"); WiFi.begin(ssid, pss); digitalWrite(0, LOW); digitalWrite(2, HIGH); } else { Serial.println("Connected"); digitalWrite(0, HIGH); digitalWrite(2, LOW); } 

to connect with remembered STA mode, ssid and password, but with static IP address

 WiFi.setAutoConnect(false); IPAddress ip(192, 168, 1, 8); IPAddress gw(192, 168, 1, 1); IPAddress sn(255, 255, 255, 0); WiFi.config(ip, gw, sn, gw); WiFi.begin(); // uses remembered ssid and password WiFi.waitForConnectResult(); 

The esp8266 SDK libraries starts the STA connection, but it is handled by other thread then the Arduino sketch. You can wait for this connection in setup with waitForConnectResult. It returns status().

 if (WiFi.waitForConnectResult() != WL_CONNECTED) { Serial.println("Not connected"); WiFi.begin(ssid, pss); digitalWrite(0, LOW); digitalWrite(2, HIGH); } else { Serial.println("Connected"); digitalWrite(0, HIGH); digitalWrite(2, LOW); } 

The esp8266 SDK libraries starts the STA connection, but it is handled by other thread then the Arduino sketch. You can wait for this connection in setup with waitForConnectResult. It returns status().

 if (WiFi.waitForConnectResult() != WL_CONNECTED) { Serial.println("Not connected"); WiFi.begin(ssid, pss); digitalWrite(0, LOW); digitalWrite(2, HIGH); } else { Serial.println("Connected"); digitalWrite(0, HIGH); digitalWrite(2, LOW); } 

to connect with remembered STA mode, ssid and password, but with static IP address

 WiFi.setAutoConnect(false); IPAddress ip(192, 168, 1, 8); IPAddress gw(192, 168, 1, 1); IPAddress sn(255, 255, 255, 0); WiFi.config(ip, gw, sn, gw); WiFi.begin(); // uses remembered ssid and password WiFi.waitForConnectResult(); 
edited body
Source Link
Juraj
  • 18.3k
  • 4
  • 32
  • 50

The esp8266 SDK libraries starts the STA connection, but it is handled by other thread thanthen the Arduino sketch. You can wait for this connection in setup with waitForConnectResult. It returns status().

 if (WiFi.waitForConnectResult() != WL_CONNECTED) { Serial.println("Not connected"); WiFi.begin(ssid, pss); digitalWrite(0, LOW); digitalWrite(2, HIGH); } else { Serial.println("Connected"); digitalWrite(0, HIGH); digitalWrite(2, LOW); } 

The esp8266 SDK libraries starts the STA connection, but it is handled by other thread than the Arduino sketch. You can wait for this connection in setup with waitForConnectResult. It returns status().

 if (WiFi.waitForConnectResult() != WL_CONNECTED) { Serial.println("Not connected"); WiFi.begin(ssid, pss); digitalWrite(0, LOW); digitalWrite(2, HIGH); } else { Serial.println("Connected"); digitalWrite(0, HIGH); digitalWrite(2, LOW); } 

The esp8266 SDK libraries starts the STA connection, but it is handled by other thread then the Arduino sketch. You can wait for this connection in setup with waitForConnectResult. It returns status().

 if (WiFi.waitForConnectResult() != WL_CONNECTED) { Serial.println("Not connected"); WiFi.begin(ssid, pss); digitalWrite(0, LOW); digitalWrite(2, HIGH); } else { Serial.println("Connected"); digitalWrite(0, HIGH); digitalWrite(2, LOW); } 
Source Link
Juraj
  • 18.3k
  • 4
  • 32
  • 50

The esp8266 SDK libraries starts the STA connection, but it is handled by other thread than the Arduino sketch. You can wait for this connection in setup with waitForConnectResult. It returns status().

 if (WiFi.waitForConnectResult() != WL_CONNECTED) { Serial.println("Not connected"); WiFi.begin(ssid, pss); digitalWrite(0, LOW); digitalWrite(2, HIGH); } else { Serial.println("Connected"); digitalWrite(0, HIGH); digitalWrite(2, LOW); }