What's going on with my WiFi.h?

So, about a year ago when I was getting into this I did some little sketches that connected to my wifi ok using ESP32 dev boards.
More recently I've got some ESP8266 boards downloaded the libraries and copied an old sketch with WiFi and tried to compile it. No joy because the WiFi.config line needed 5 arguments. Puzzled I looked into the header file and found that I had several dotted around my C drive. The error message told me there were multiples and which one it was trying to use and sure enough in that the .config routine needed 5 arguments (no other variants (overloads)) existed. I set them up and it worked so I moved on.
Today I've gone back to create another 8266 sketch and started by copying the code block that worked recently. When I came to compile it, the error message told me that the .config needed 1, 2, 3, or 4 arguments! So, again I look at the WiFi.h files I have and I cannot find the one needed exactly 5 arguments just the one needing 1, 2, 3, or 4!
I feel I'm going mad. can anyone explain and help me out here?

I'm running on a Windows 10 PC with the main Arduino stuff in Program Files (86). The ESP32 and 8266 are in My Documents.

There is no WiFi.h for the ESP8266. The ESP8266 platform's library is called ESP8266WiFi, and the primary header file name is ESP8266WiFi.h:
https://arduino-esp8266.readthedocs.io/en/2.7.4_a/esp8266wifi/readme.html

It's likely that you're getting the ancient WiFi library that is built-in with the Arduino IDE. That library was written for the long retired Arduino WiFi Shield, which is completely different from the ESP8266.

The ESP8266WiFi library's API was based on the WiFi library API, so you will find that there are a lot of similarities between the two, but there are also differences.

To make things more confusing, the ESP32 WiFi library is called "WiFi", and does use the WiFi.h header filename. When you have an ESP32 board selected from the Arduino IDE"s Tools > Board menu, the ESP32 WiFi library will automatically be used, but when you have an ESP8266 board selected, the only WiFi library available is the one for the Arduino WiFi Shield.

pert

Thanks. I've managed to find the ESP8266WiFi (and other 8266 and 32 stuff) in the windows User/application data/local/.... area and will use it from now on. Just changing the header to ESP8266WiFi.h solved the problem and now my new sketch is compiling OK and connecting to the WiFi, as all my old sketches used to.

It's weird the way things are spread about on my C drive.

Thanks again.

You're welcome. I'm glad to hear it's working now!

Wingnut:
It's weird the way things are spread about on my C drive.

There are 3 locations for library files:

  • Sketchbook: {sketchbook folder}/libraries. The sketchbook folder location can be found (or changed) at File > Preferences > Sketchbook location:. This is the location of libraries installed via Library Manager (Sketch > Include Library > Manage Libraries...) or Sketch > Include Library > Add .ZIP Library. You should also manually install libraries to that location.

  • IDE: {Arduino IDE install folder}/libraries. This is for the libraries included with the Arduino IDE installation. You should never install libraries to that folder because they will be lost when you update to a new IDE version.

  • Core: This is dependent on the current selection in Tools > Board. Location will depend on if you're using a hardware core bundled with the IDE, installed via Boards Manager, or manually installed to {sketchbook folder}/hardware. The best way to find it is to do:

  • File > Examples > SPI > BarometricPressureSensor (or any other SPI library example sketch)

  • Sketch > Show Sketch Folder - this will open the SPI/examples/BarometricPressureSensor folder inside of the current hardware core's libraries folder

To find any library do this:

  • File > Examples > open any example from the library you want to find
  • Sketch > Show Sketch Folder - this will open the example sketch folder inside of the library folder.

So it's normal for library files to be in several locations and each location listed above has a specific reason for existing. If you are still perplexed by any of the library files you're finding, you can provide some details and I'll try to explain what the deal is.