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

I’m trying to compile a project which uses ESP8266WiFi.h (GitHub - absalom-muc/MHI-AC-Ctrl: Reads and writes data (e.g. power, mode, fan status etc.) from/to a Mitsubishi Heavy Industries (MHI) air conditioner (AC) via SPI controlled by MQTT

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>             // https://github.com/espressif/arduino-esp32/tree/master/libraries/WiFi
#include <PubSubClient.h>     // https://github.com/knolleary/pubsubclient
#include <ArduinoOTA.h>       // https://github.com/espressif/arduino-esp32/tree/master/libraries/ArduinoOTA

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!