Please help a rooky ESP8266WiFi.h problem

Sorry I am completly new with PIO. I’m not a good software man, but I try to be better :wink: (I am a better hardware man).

The start of my script

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <PubSubClient.h>
#include <ArduinoJson.h>

ESP8266WiFi.h generate 2 errrors
#Include errors detected. Update includePath. Tildes are disabled for this translation unit (D: \ Users \ Phil \ OneDrive \ Documents \ PlatformIO \ Projects \ Test-MQTT \ src \ main.cpp). C / C ++ (1696)”
And
“cannot open source file “ESP8266WiFi.h” C / C ++ (1696)”

I don’t know how to solve this. Please HELP

Does the project compile?

If yes, does a Ctrl+Shift+P → Rebuild IntelliSense help? If no, what is the error message?

Unfortunately it does not compile, see the result below :

Dependency Graph
|-- 0.16.0
|-- 6.18.5
|-- 2.8.0
|-- 1.1.1
| |-- 1.0
|-- 1.0
Building in release mode
Compiling .pio\build\az-delivery-devkit-v4\src\main.cpp.o
Generating partitions .pio\build\az-delivery-devkit-v4\partitions.bin
Compiling .pio\build\az-delivery-devkit-v4\libad7\WiFiManager\WiFiManager.cpp.o
Compiling .pio\build\az-delivery-devkit-v4\lib201\PubSubClient\PubSubClient.cpp.o
Compiling .pio\build\az-delivery-devkit-v4\lib4ab\WiFi\ETH.cpp.o
Compiling .pio\build\az-delivery-devkit-v4\lib4ab\WiFi\WiFi.cpp.o
Compiling .pio\build\az-delivery-devkit-v4\lib4ab\WiFi\WiFiAP.cpp.o
Compiling .pio\build\az-delivery-devkit-v4\lib4ab\WiFi\WiFiClient.cpp.o
Compiling .pio\build\az-delivery-devkit-v4\lib4ab\WiFi\WiFiGeneric.cpp.o
In file included from .pio\libdeps\az-delivery-devkit-v4\WiFiManager\WiFiManager.cpp:13:0:
.pio\libdeps\az-delivery-devkit-v4\WiFiManager\WiFiManager.h:16:25: fatal error: ESP8266WiFi.h: No such file or directory


  • Looking for ESP8266WiFi.h dependency? Check our library registry!
  • CLI > platformio lib search “header:ESP8266WiFi.h”
  • Web > PlatformIO Registry

compilation terminated.
*** [.pio\build\az-delivery-devkit-v4\libad7\WiFiManager\WiFiManager.cpp.o] Error 1
src\main.cpp:2:25: fatal error: ESP8266WiFi.h: No such file or directory


  • Looking for ESP8266WiFi.h dependency? Check our library registry!
  • CLI > platformio lib search “header:ESP8266WiFi.h”
  • Web > PlatformIO Registry

compilation terminated.
*** [.pio\build\az-delivery-devkit-v4\src\main.cpp.o] Error 1

az-delivery-devkit-v4 is an ESP32 board. The header file ESP8266WiFi.h is for ESP8266 microcontroller. So it looks like you have code for the wrong microcontroller.

I guess you have started with a code example. Unfortunately, it’s not suitable for your board. You have to find one suitable for ESP32.

Yes it is a code example which I tried to test :upside_down_face:
I now need to find the good library for an ESP32 but, it seems not so easy :thinking:

Many thanks for your precious help

You don’t really need to look for another library. The same MQTT and Json libraries work on the ESP32 as well. And WiFi is part of the ESP32 Arduino core. Instead, you probably want to look for a suitable code example. That shouldn’t be too hard.