ESP8266WiFi.h: No such file or directory

May 2024 ยท 1 minute read

How can I make the WifiManager library work on a ESP32 board? I'm using PlatformIO to develop my code.

Here are my imports:

#include "esp_camera.h" #include <Arduino.h> #include <WiFiClientSecure.h> #include <PubSubClient.h> #include <ArduinoJson.h> #include <EEPROM.h> #include <WiFiManager.h> WiFiClient espClient; PubSubClient client(espClient); WiFiManager wifiManager; 

platformio.ini

[env:esp32cam] platform = espressif32 board = esp32cam framework = arduino monitor_speed = 115200 build_flags = -DMQTT_MAX_PACKET_SIZE=36000 lib_deps = espressif/esp32-camera@^1.0.0 knolleary/PubSubClient@^2.8 bblanchon/ArduinoJson@^6.18.5 tzapu/WiFiManager@^0.16.0 

But when I run the code, I get this following error:

.pio\libdeps\esp32cam\WiFiManager/WiFiManager.h:16:25: fatal error: ESP8266WiFi.h: No such file or directory 

After further research, I see that WiFiManager uses ESP8266WiFi.h and now I'm wondering how I can make this library work on my ESP32 or is there an alternative library? The project's readme does say it works on ESP32.

4

1 Answer

The latest release of WiFiManager library (0.16) is almost a year old and doesn't support ESP32.
You will need to install the library from Github to get ESP32 support.

In your platformio.ini replace

tzapu/WiFiManager@^0.16.0 

with

https://github.com/tzapu/WiFiManager.git@^2.0.5-beta 
2

ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobXJxaGeBeH%2BOnqqpcGJrg7i1xaJkoWWepHq0wcKhZJ%2BhnJp6sL6MnaCrnZOpvLPF