Problem:
When compiling your PlatformIO firmware, you see an error message like
src/main.cpp: In function 'void setup()': src/main.cpp:49:10: error: 'class WiFiClass' has no member named 'mode' 49 | WiFi.mode(WIFI_STA); | ^~~~ src/main.cpp:49:15: error: 'WIFI_STA' was not declared in this scope 49 | WiFi.mode(WIFI_STA); | ^~~~~~~~
Solution:
You included WiFi.h
instead of the correct ESP8266WiFi.h
. This will cause multiple issues like reboots on WiFi.begin()
even if it compiles correctly.
Replace
#include <WiFi.h>
with
#include <ESP8266WiFi.h>
everywhere in your source code and does not support
WiFi.mode(WIFI_STA);
For more details, see our previous post on How to fix PlatformIO ESP8266 WiFi.h: No Such File or Directory