ESP8266WiFi library not found - fatal error

I am just new in using Atom after having used Arduino IDE since years. My computers are using Windows 10.

From Arduino i imported a project for ESP32/ESP8266 with a testprogram for customizing parameters in a configfile in SPIFFS. The wifimanager is included in the main program.

The program which was compiling in Arduino IDE without problems does not compile in Atom.

Error message:

C:/Users/xxxx/.platformio/lib/WifiManager_ID567/WiFiManager.h:16:25: fatal error: ESP8266WiFi.h: No such file or directory

In Arduino i could define a compiler switch called ‘ESP8266’ which lets the compiler either use just one of the libraries WIFI.h or ESP8266wifi.h.

In the library registry i could not fin ESP8266WiFi

Now my question: How can i get the ESPWiFi.h/.cpp to the correct directory?

Thank you in advance for any helpful hint!

best regards

Sounds like lib_ldf_mode = deep+ (or chain+) is needed for the library dependency finder (LDF) to be able to include the correct library. See documentation.

1 Like

You don’t need to install ESP8266WiFi via the registry, it’s bundled with the ESP8266 core.

If you’re switching between Wifi.h and ESP8266WiFi.h using a define, then as maxgerhardt pointed out, you’ll probaly need to use one of the + variants of the ldf mode.

The two problems you’re likely to encounter next if you’re not familar with PlatformIO, or more correctly, proper C++, is the need to add #include <Arduino.h to the top of your main source file if you don’t have it already, and the need to forward declare functions before use

Hi magerhardt,

thanks for replying!

I stripped my program down to a minimal test:

//#define ESP8266
#include <WiFi.h>
#include <WebServer.h>
#include <DNSServer.h>
#include <WiFiManager.h>
void setup() {
delay(1000);
}
void loop() {
}

I inserted your LDF-proposal in my ini-file which now looks like:

[env:esp32doit-devkit-v1]
platform = espressif32
lib_ldf_mode = deep+
board=nodemcu-32s
framework = arduino

I still can not compile witout the error:

WiFiManager.h:16:25: fatal error: ESP8266WiFi.h: No such file or directory

Would be nice if you could try out my examole. Maybe you could tell me what is wrong with it and what you did change to make it running…

Thanks in advance!

best regards

Are you using the development version of WifiManager? As the standard release version does not have ESP32 support (which is why it’s trying to include the ESP8266 WiFi library…

You can use the development version by changing the lib_deps line in your platformio.ini to lib_deps = https://github.com/tzapu/WiFiManager#development

i.e. for two environments - ESP32 and ESP8266

[env]
framework = arduino
lib_ldf_mode = deep+
lib_deps = https://github.com/tzapu/WiFiManager#development

[env:esp32doit-devkit-v1]
platform = espressif32
board=nodemcu-32s

[env:d1_mini]
platform = espressif8266
board=d1_mini

the following code will compile and correctly auto-switch the includes (as ESP8266 and ESP32 are defined by the cores).

#include <Arduino.h>
#if defined(ESP8266)
#include <ESP8266WiFi.h>
#elif defined(ESP32)
#include <WiFi.h>
#include <WebServer.h>
#else
#error Invalid platform
#endif
#include <DNSServer.h>
#include <WiFiManager.h>

void setup()
{
  delay(1000);
}

void loop()
{
}

But the conditional includes are only needed if you intend to work on a dual/multi-platform project.

Hi pfeerick,
Hi magerhardt,

thank you for your help - and please excuse my late reaction!

In the meantime i used the wifimanager to develop my own branch. I am almost fininished - no fatal errors anymorde and less memory consuming. Only the custom parameter transfer has to be finished.

If somebody wants i could share my new code. But i am still not familiar with github…

Thanks anyway!
fhpa

1 Like

how did you solve the problem? what is your sample code? i am having the same problem. Can you help me?

1 Like