Problem:
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 > https://platformio.org/lib/search?query=header:WiFi.h * ************************************************************** 2 | #include <WiFi.h>
Solution:
Instead of
#include <WiFi.h>
use
#include <ESP8266WiFi.h>
Now delete the .pio
folder from the project directory to ensure a clean build by using:
rm -rf .pio
In case that doesn’t help, see our article on how to fix this issue by adding the WiFi library to the dependencies: How to fix PlatformIO WiFi.h: No Such File or Directory