| by Arround The Web | No comments

Arduino IDE Can’t Find ESP8266WiFi.h: No such file or directory

The ESP8266 is a Wi-Fi based board that can provide wireless connectivity to various projects. The ESP8266 board like ESP32 can also be programmed with Arduino IDE. However, users may encounter an error message that says “ESP8266 No such file or directory” while trying to program the ESP board. This article covers the possible reasons for this error and how to fix it.

How to Fix “ESP8266 No such file or directory” Error

The “ESP8266 No such file or directory” error typically occurs when you’re trying to compile code for the ESP8266 microcontroller, and the IDE or compiler can’t find the necessary files to complete the process.

The error message usually occurs when the ESP8266WiFi library is missing or not installed correctly. The ESP8266 board core must be installed in Arduino IDE to resolve this error.

Note: The ESP8266WiFi.h is by default added to Arduino IDE once we install the ESP8266 board core in Arduino IDE. It means if the board core is not properly installed, we have to reinstall it from the start to make the WiFi libraries run without any error.

Now we will cover some possible solutions for this error.

Solution 1: Install the ESP8266 Board Core

Main cause for the ESP8266WiFi.h error is usually the missing ESP8266 installation in the Arduino IDE. To program ESP8266 the corresponding board cores must be installed in IDE.

The ESP8266 Arduino Core is a C++-based firmware that helps users to program ESP8266 boards with IDE and control the WiFi and other wireless components of this board. For detailed information on the ESP8266 Arduino Core visit the GitHub repository for ESP8266 [ESP8266 Arduino Board Core].

You can also install the ESP8266 in IDE using the JSON file from the following steps:

Step 1: First, open the Arduino IDE and go to preferences. In the Preferences window, look for the “Additional Boards Manager URLs” field. In this field, enter the following URL:

http://arduino.esp8266.com/stable/package_esp8266com_index.json

Note: If you already have the ESP32 boards URLs, separate them with commas as follows:

https://dl.espressif.com/dl/package_esp32_index.json, http://arduino.esp8266.com/stable/package_esp8266com_index.json

Step 2: Once you’ve entered the URL, click the “OK” button to save the changes.

Step 3: After that, go to the Arduino board manager and search for “esp8266”. Click “Install” to begin the ESP8266 installation in Arduino IDE.

Graphical user interface, text, application Description automatically generated

Once the ESP8266 is successfully added, reopen the IDE and again compile the code, this will solve the error.

Solution 2: Add the Correct Header File for ESP8266WiFi.h Library

Second reason that can lead to an ESP8266WiFi.h library error is the use of the wrong header file. If you are using ESP8266 with an Arduino board, ensure that you use the header file “ESP8266WiFi.h” and not “WiFi.h”, which is used for ESP32. If you are using a different platform or microcontroller, ensure that you use the correct header file.

In your Arduino sketch, make sure that you have included the “ESP8266WiFi.h” header file at the beginning of your code. To add this library to your sketch, use the following keyword at beginning of the Arduino sketch:

#include <ESP8266WiFi.h>

 

Solution 3: Reinstall the ESP8266 Board

Third reason on the list is missing the ESP8266 file path which may lead to this error. Try checking the file path of the header file. Make sure that the path is correct and located at a specified location.

All the additional boards installed in Arduino IDE can be viewed inside the Arduino15 folder.

C:\Users\username\AppData\Local\Arduino15\packages

Make sure the ESP8266 folder is present inside the Arduino15 directory as shown in the image below.

Alternatively, you can also verify the correct installation of the ESP8266 WiFi library by going to Sketch>Include Library>ESP8266WiFi

This will open a new window. This code is displaying all the installed ESP8266 WiFi libraries in Arduino IDE. If you found any of the libraries missing try reinstalling the ESP8266 board in Arduino IDE as mentioned above in solution 1.

Graphical user interface, text, application Description automatically generated

Conclusion

The ESP8266WiFi library error “No such file or directory” occurs when the Arduino IDE fails to find the path of this library. This error can also occur because of a missing header file or because the ESP8266 board core is not installed properly. By following the solutions outlined in the article, this error can be easily solved.

Share Button

Source: linuxhint.com

Leave a Reply