How to fix PlatformIO WiFi.h: No Such File or Directory

Important note: On the ESP8266, this solution is not recommended. See How to fix PlatformIO ESP8266 WiFi.h: No Such File or Directory instead


When compiling your PlatformIO firmware, you see an error message like

src/main.cpp:2:10: fatal error: WiFi.h: No such file or directory

* Looking for WiFi.h dependency? Check our library registry!
* CLI  > platformio lib search "header:WiFi.h"
* Web  >

    2 | #include <WiFi.h>


Add WiFi to the lib_deps in platformio.ini (create lib_deps if it is not present already):

lib_deps =

and then recompile.

Complete platformio.ini example:

platform = espressif8266
board = d1_mini_lite
framework = arduino
monitor_speed = 115200
lib_deps =
    ESP Async [email protected]
    [email protected]