PlatformIO Community

Stuck! Fatal error: ESP8266WiFi.h: No such file or directory when compiling

I’m trying to compile a project which uses ESP8266WiFi.h (

It compiles fine if I select a Wemos D2 board, but if I select the board I’m actually using - a Wemos LOLIN S2 Mini, I get a compiler error of “fatal error: ESP8266WiFi.h: No such file or directory”

The board is officially supported according to this page: WEMOS LOLIN S2 Mini — PlatformIO latest documentation

What am I doing wrong? From what I’ve read, this is a standard Arduino library and therefore should not need to be added to lib_deps.

There are other threads mentioning the same error, but the fixes in those threads are not working for me (like adding lib_ldf_mode = deep+ to platformio.ini).

Any help greatly appreciated!


Your selected board, the lolin_s2_mini, is an ESP32-S2 based board.

So understandably you’re getting an error when attempting to include ESP8266WiFi.h, this library is for ESP8266 boards and not contained in Arduino-ESP32.

If you want to run this project, that is intended for ESP8266 boards, on your ESP32S2 board, you will need to do some porting on the source code level. Specifically, the includes in

would have to be exchanged with

#include <WiFi.h>             //
#include <PubSubClient.h>     //
#include <ArduinoOTA.h>       //

there may be other source modifications needed, e.g. if the API for some objects is different, but this is should be a starting point.

OK so it sounds like ESP32 boards aren’t direclty supported by the project I’m using without modification, but thankfully I have an ESP8266 board spare I can try. Thanks!