Code compilation error - NodeMCU 1.0 (ESP-12E Module)

This is my first time working with ESP8266 NodeMCU and I was able to successfully run the Blink program and get the on-board blinking. However, when I try the below sample program I get the error:
Multiple libraries were found for "ESP8266WiFi.h"
Used: C:\Users\XXXXX\Documents\Arduino\libraries\ESP8266WiFi
Not used: C:\Users\XXXXX\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\libraries\ESP8266WiFi
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

Program:

#include <ESP8266WiFi.h>

void setup()
{
  Serial.begin(115200);
  Serial.println();

  WiFi.begin("MY_SSID", "PWD");

  Serial.print("Connecting");
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
  }
  Serial.println();

  Serial.print("Connected, IP address: ");
  Serial.println(WiFi.localIP());
}

void loop() 
{}

I know a similar topic has been posted multiple times earlier, however I tried most of these steps and still not able to resolve this error. I am using Arduino IDE 1.8.19 with ESP8266 (3.0.1) Board Manager version, and I have this URL (https://arduino.esp8266.com/stable/package_esp8266com_index.json) configured in my preferences for additional boards. Kindly help.

I suggest you remove the version

Used: C:\Users\XXXXX\Documents\Arduino\libraries\ESP8266WiFi

since that does not belong to the core, but maybe to an older version of the ESP core. You should be using the other version.

Thanks. I deleted C:\Users\XXXXX\Documents\Arduino\libraries\ESP8266WiFi but then it started giving some other error. So, I reneamed "C:\Users\XXXXX\AppData\Local\Arduino15" and restarted my Arduino IDE, added the URL for additional board and reinstalled the board manager for ESP8266 and now it can compile.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.