31

I am trying to use NOD MCU ESP8266WiFi with Arduino IDE

When I run this code:

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "YourAuthToken";
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";

void setup(){
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
}
void loop()
{
  Blynk.run();
}

I get the following error:

fatal error: ESP8266WiFi.h: No such file or directory

     #include <ESP8266WiFi.h>    
                         ^
compilation terminated.

exit status 1
Error compiling for board Arduino/Genuino Uno.
2
  • 6
    for me, it was as simple as remembering to select the right board: Tools > Board > Generic ESP8266 Module Commented Jan 30, 2021 at 0:28
  • Thanks, Ryan! That's a real time saver! In my case, I had switched to ESP32 for a different project, and didn't realize I had to switch board back (to 8266) when I resumed work on my original project. I was about to go looking for what had happened to the Wifi libraries... would have wasted a lot of time :)
    – joakimk
    Commented Oct 30, 2023 at 21:59

4 Answers 4

53

When programming the NODEMCU card with the Arduino IDE, you need to customize it and you must have selected the correct card.

Open Arduino IDE and go to files and click on the preference in the Arduino IDE.

Add the following link to the Additional Manager URLS section: "http://arduino.esp8266.com/stable/package_esp8266com_index.json" and press the OK button.

Then click Tools> Board Manager. Type "ESP8266" in the text box to search and install the ESP8266 software for Arduino IDE.

You will be successful when you try to program again by selecting the NodeMCU card after these operations. I hope I could help.

3
  • 2
    Works like charm. Commented Oct 12, 2018 at 15:29
  • 3
    To be clear on gokhan's last point: if you have a different board selected (like an ESP32, in my case), under Tools->Board, then the compiler will not find the ESP8266WiFi.h header file. Arduino IDE 1.8.13 Commented Aug 21, 2021 at 21:40
  • I have NodeMCU-32S board, and in Arduino IDE I have NodeMCU-32S board selected, and there is no ESP8266WiFi.h. Commented Dec 20, 2022 at 19:03
30

Starting with 1.6.4, Arduino IDE can be used to program and upload the NodeMCU board by installing the ESP8266 third-party platform package (refer https://github.com/esp8266/Arduino):

  • Start Arduino, go to File > Preferences
  • Add the following link to the Additional Boards Manager URLs: http://arduino.esp8266.com/stable/package_esp8266com_index.json and press OK button
  • Click Tools > Boards menu > Boards Manager, search for ESP8266 and install ESP8266 platform from ESP8266 community (and don't forget to select your ESP8266 boards from Tools > Boards menu after installation)

To install additional ESP8266WiFi library:

  • Click Sketch > Include Library > Manage Libraries, search for ESP8266WiFi and then install with the latest version.

After above steps, you should compile the sketch normally.

EDIT: the lib might have already been included in the later version of Arduino IDE, so firstly, check if it is included, then if not yet, install it, you can refer below link for a systematic guidance on how to debug such kind of issue: https://www.programmingelectronics.com/no-such-file-error/

6
  • I did this, then had to do as intructed here: arduino-esp8266.readthedocs.io/en/latest/faq/…
    – minisaurus
    Commented Sep 22, 2019 at 16:58
  • 28
    ESP8266WiFi doesn't seem to be in the Library Manager listing anymore.
    – Jaxian
    Commented Jan 14, 2020 at 14:38
  • 1
    I couldn't find this lib in the manager either. The code compiled nevertheless (on a freshly set up computer), so I assume that it is included in the Arduino IDE installation (or the board configs?) now. I'm using Arduino IDE 1.8.15.
    – Fred
    Commented Nov 25, 2021 at 21:32
  • 1
    @Fred: I the link I gave said: "An easy way to check to see if you have that file is to be in the Arduino IDE and go to Sketch > Include Library, and then look for the name of that library." - you can check if the lib was included?
    – lhchuopp
    Commented Nov 27, 2021 at 0:00
  • 1
    @StevenLee: Clicking on "ESP8266WiFi" in the include library menu adds 18 includes which all seem to be related to esp wifi. #6 is <ESP8266WiFi.h> which I had used in my original code. So yes, it seems to be included in the IDE installation.
    – Fred
    Commented Nov 28, 2021 at 2:51
6

Just don't forget to select your board, after install

4

For those who are having trouble with fatal error: ESP8266WiFi.h: No such file or directory, you can install the package manually.

  1. Download the Arduino ESP8266 core from here https://github.com/esp8266/Arduino
  2. Go into library from the downloaded core and grab ESP8266WiFi.
  3. Drag that into your local Arduino/library folder. This can be found by going into preferences and looking at your Sketchbook location

You may still need to have the http://arduino.esp8266.com/stable/package_esp8266com_index.json package installed beforehand, however.

Edit: That wasn't the full issue, you need to make sure you have the correct ESP8266 Board selected before compiling.

Hope this helps others.

Not the answer you're looking for? Browse other questions tagged or ask your own question.