Reputation: 23
I'm trying to use ESP8266 module and i used esp8266wifi.h. but it doesn't work :( Will you help me?? Here's my codes. I tried to find multiple libraries of "ESP8266WiFi.h", but i couldn't find any of multiple libraries.
#include "ESP8266WiFi.h"
#include "WiFiUDP.h"
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() {
Serial.begin(115200);
connectWifi();
Udp.begin(localUdpPort);
}
void loop() {
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. And will you tell me what "queue.h" means?? I can't find it.
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.
Upvotes: 1
Views: 5350
Reputation: 56
You mentioned that you would like to use ESP8266 as a standalone module (not as a secondary MCU, controlled by AT commands) but according to the log, the compiler is trying to translate for Arduino/Genuino Uno board. I think the first step should be to check the board settings and install the necessary packages, if the required one is not available.
Upvotes: 3