Multiple libraries were found for "ESP8266WiFi.h"

Hi, I'm trying to use ESP8266 module and i used esp8266wifi.h.
but it doesn't work :frowning: Will you help me??

#include "ESP8266WiFi.h"
#include  "WiFiUDP.h"

//Wifi 연결하기
const char* ssid = "your ssid";
const char* password = "your password";

WiFiUDP Udp;
unsigned int localUdpPort = 4210;
char incomingPacket[255];
char replyPacket[] = "Hi there! Got the message.";

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);

   //wifi연결
  connectWifi();

  //Udp setup
  Udp.begin(localUdpPort);
 
}

void loop() {
  // put your main code here, to run repeatedly:
  int packetSize = Udp.parsePacket();
  if(packetSize){
    Serial.printf("Received %d bytes from %s, port %d\n", packetSize, Udp.remoteIP().toString().c_str(), Udp.remotePort());
    int len = Udp.read(incomingPacket, 255);
    if (len > 0)
    {
      incomingPacket[len] = 0;
    }
    Serial.printf("UDP packet contents: %s\n", incomingPacket);

    // send back a reply, to the IP address and port we got the packet from
    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
    Udp.write(replyPacket);
    Udp.endPacket();
    delay(1000); // Need a delay otherwise the data is not sent Was 3000
  }

}


void connectWifi(){
  Serial.print("Connecting to ");
  Serial.print(ssid);

  WiFi.disconnect(true);
  delay(1000);
  WiFi.begin(ssid, password);
  while(WiFi.status() != WL_CONNECTED){
    delay(500);
    Serial.print(".");
    
  }
  
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.print("IP Address: ");
  Serial.print(WiFi.localIP());
  Serial.println("");
}

And here's my error messages.

Arduino: 1.8.10 (Windows 10), Board: "Arduino/Genuino Uno"

Multiple libraries were found for "ESP8266WiFi.h"
In file included from C:\Program Files (x86)\Arduino\libraries\ESP8266WiFi\src/ESP8266WiFi.h:33:0,

 Used: C:\Program
                 from C:\Users\user\Desktop\sketch_dec18b\sketch_dec18b\sketch_dec18b.ino:1:

C:\Program Files (x86)\Arduino\libraries\ESP8266WiFi\src/ESP8266WiFiType.h:26:10: fatal error: queue.h: No such file or directory

 #include <queue.h>

          ^~~~~~~~~

compilation terminated.

exit status 1
Error compiling for board Arduino/Genuino Uno.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

https://forum.arduino.cc/index.php?topic=442690.0

See if that helps any.

I feel your pain. I can't seem to find the library that actually contains ESP8266WiFi.h. I keep going in circles at github with the arduino-master zip file. This appears to be a chronic problem according to a google search, possibly with the IDE importing libraries. I finally got the "master" zip down loaded from github to the desktop, but getting the IDE to import the zip appears to be futile. If anyone knows where to put the unzipped folder, but that would be helpful.

Update on my issue, I just copied all the library files from inside the zip file and put them in the library folder of the IDE. ESP8266WiFi.h appears to be found now. DIY seems to have worked, so far.

#include "ESP8266WiFi.h"
#include  "WiFiUDP.h"

This is telling the Compiler to look for the libraries within the 'sketch folder'
, you probably mean

#include <ESP8266WiFi.h>
#include  <WiFiUDP.h>

That way it will look in the core-libraries, and personal libraries folder, where any files on which it depends are usually also found.

ESP8266WiFi.h

is a built-in library to the ESP-core, if your core is properly installed, you should not have to install it manually.

emtae55:
C:\Program Files (x86)\Arduino\libraries\ESP8266WiFi\src/ESP8266WiFiType.h:26:10: fatal error: queue.h: No such file or directory

#include <queue.h>

^~~~~~~~~

compilation terminated.

exit status 1
Error compiling for board Arduino/Genuino Uno.

The cause of the error is that you are trying to compile the ESP8266WiFi library for the Uno board. The ESP8266WiFi library is written specifically for use when you are directly programming the ESP8266 using the ESP8266 core for Arduino. You might have noticed that it was very difficult to even install the ESP8266WiFi library. That is because it's intended to be bundled with the ESP8266 core for Arduino. It is not intended to be installed separately from the core and doing so may cause you problems later. I recommend you to delete your installation of ESP8266WiFi Library to avoid this.

So now whyat you need to do is tell us what you mean by this:

emtae55:
I'm trying to use ESP8266 module

Are you trying to program the ESP8266 directly? If so, you need to install the ESP8266 core for Arduino, following these instructions:

and then select the appropriate board from the Arduino IDE's Tools > Board menu.

Or are you trying to use the ESP8266 just as a WiFi adapter module connected to an Uno board? If so you can't use the ESP8266WiFi library. There is a library I recommend for this usage:

zoomkat:
I can't seem to find the library that actually contains ESP8266WiFi.h.

It's here:

zoomkat:
I finally got the "master" zip down loaded from github to the desktop, but getting the IDE to import the zip appears to be futile.

That should be a clue that you're going down the completely wrong path.

zoomkat:
If anyone knows where to put the unzipped folder, but that would be helpful.

Don't put it anywhere. Follow the installation instructions in the readme:

zoomkat:
Update on my issue, I just copied all the library files from inside the zip file and put them in the library folder of the IDE. ESP8266WiFi.h appears to be found now. DIY seems to have worked, so far.

Noooo! First of all, this library was never intended to be installed separately from the ESP8266 core for Arduino, as I already explained. Second, you should never install anything to the IDE installation folder. The reason is that anything you put in that folder will be lost when you update to a new version of the IDE. When you do need to do a manual library installation, you should put it in the libraries subfolder of the sketchbook folder. You can find the sketchbook folder location in the Arduino IDE at File > Preferences > Sketchbook location.

Deva_Rishi:

#include "ESP8266WiFi.h"

#include  "WiFiUDP.h"


This is telling the Compiler to look for the libraries within the 'sketch folder'

Actually it's telling the compiler to look in the current folder first, then in the rest of the include search path. So if a library is installed normally, you can use either the double quotes or the angle brackets #include syntax and both will work. The only time you need to use one in particular is when you are #including a file that is not in the include search path (such as a file in the sketch folder), in which case you must use the double quotes syntax. However, when the file is in the include search path, the most correct syntax is angle brackets, and so I would use that in this case. But I wouldn't inflict that sort of pedantry on @emtae55 at this stage in their learning journey because they are already plenty confused enough.

Update on my progress, I got the esp8266 list of boards added to the boards list, so I now I have a board choice to compile for. I got some typical esp8266 code to use as a test. I still got the ESP8266WiFi.h not found, so I went to the add library, scrolled down and clicked the ESP8266WiFi and a bunch of includes from that library appeared in the top of the code, some red and some dark. Removed the dark ones and the code compiled. Interesting that the original "#include <ESP8266wifi.h>" stays dark.

That's because filenames are case sensitive in Arduino sketches (even if they are not in your OS).

ESP8266wifi.h != ESP8266WiFi.h

Note that there is no magic to that "Sketch > Include Library" feature. It just pastes #include directives for all the .h files in the library into the top of your sketch. Nothing more. There is absolutely no difference between you typing the #include directives in manually.

"ESP8266wifi.h != ESP8266WiFi.h"

Interesting point, I corrected the capitalization and the board recognized it. This may be the answer to the issue in another current discussion.

Note that the coloration of filenames in #include directives by the Arduino IDE is not terribly meaningful. Library authors can define arbitrary keywords for their libraries. The Arduino IDE blindly colors these keywords wherever they occur in the sketch, with no regard to context. And it does this for the keywords of every installed library, even if you aren't using that library in your sketch. Once you get a lot of libraries installed, you will find random words colored pointlessly throughout your sketch. Often the primary header filename is the same as the library's class name, so it gets highlighted purely as a side effect. Some library authors don't bother with defining keywords at all, so nothing is colored. Some library authors attempt to define keywords, but don't format the definitions correctly, so nothing is colored. Some library authors make an initial effort to define keywords, then don't follow through as development continues, so only a random subset of the library functions are colored.