0

I'm getting the following error when I try to compile my code on my LOLIN(WeMos) D1 R1:

In file included from C:\Users\Administrator\Documents\Arduino\libraries\WiFiManager/WiFiManager.h:17,
 from C:\Users\Administrator\Desktop\from\from.ino:6:
C:\Users\Administrator\AppData\Local\Arduino15\packages\esp8266\hardware\esp82663円.0.2\libraries\ESP8266WebServer\src/ESP8266WebServer.h:47:19: error: 'HTTP_ANY' conflicts with a previous declaration
 47 | enum HTTPMethod { HTTP_ANY, HTTP_GET, HTTP_HEAD, HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_DELETE, HTTP_OPTIONS };
 | ^~~~~~~~
In file included from C:\Users\Administrator\Desktop\from\from.ino:5:
C:\Users\Administrator\Documents\Arduino\libraries\ESPAsyncWebServer-master\src/ESPAsyncWebServer.h:69:3: note: previous declaration 'WebRequestMethod HTTP_ANY'
 69 | HTTP_ANY = 0b01111111,
 | ^~~~~~~~
In file included from C:\Users\Administrator\Documents\Arduino\libraries\WiFiManager/WiFiManager.h:17,
 from C:\Users\Administrator\Desktop\from\from.ino:6:
C:\Users\Administrator\AppData\Local\Arduino15\packages\esp8266\hardware\esp82663円.0.2\libraries\ESP8266WebServer\src/ESP8266WebServer.h:47:29: error: 'HTTP_GET' conflicts with a previous declaration
 47 | enum HTTPMethod { HTTP_ANY, HTTP_GET, HTTP_HEAD, HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_DELETE, HTTP_OPTIONS };
 | ^~~~~~~~
In file included from C:\Users\Administrator\Desktop\from\from.ino:5:
C:\Users\Administrator\Documents\Arduino\libraries\ESPAsyncWebServer-master\src/ESPAsyncWebServer.h:62:3: note: previous declaration 'WebRequestMethod HTTP_GET'
 62 | HTTP_GET = 0b00000001,
 | ^~~~~~~~
In file included from C:\Users\Administrator\Documents\Arduino\libraries\WiFiManager/WiFiManager.h:17,
 from C:\Users\Administrator\Desktop\from\from.ino:6:
C:\Users\Administrator\AppData\Local\Arduino15\packages\esp8266\hardware\esp82663円.0.2\libraries\ESP8266WebServer\src/ESP8266WebServer.h:47:39: error: 'HTTP_HEAD' conflicts with a previous declaration
 47 | enum HTTPMethod { HTTP_ANY, HTTP_GET, HTTP_HEAD, HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_DELETE, HTTP_OPTIONS };
 | ^~~~~~~~~
In file included from C:\Users\Administrator\Desktop\from\from.ino:5:
C:\Users\Administrator\Documents\Arduino\libraries\ESPAsyncWebServer-master\src/ESPAsyncWebServer.h:67:3: note: previous declaration 'WebRequestMethod HTTP_HEAD'
 67 | HTTP_HEAD = 0b00100000,
 | ^~~~~~~~~
In file included from C:\Users\Administrator\Documents\Arduino\libraries\WiFiManager/WiFiManager.h:17,
 from C:\Users\Administrator\Desktop\from\from.ino:6:
C:\Users\Administrator\AppData\Local\Arduino15\packages\esp8266\hardware\esp82663円.0.2\libraries\ESP8266WebServer\src/ESP8266WebServer.h:47:50: error: 'HTTP_POST' conflicts with a previous declaration
 47 | enum HTTPMethod { HTTP_ANY, HTTP_GET, HTTP_HEAD, HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_DELETE, HTTP_OPTIONS };
 | ^~~~~~~~~
In file included from C:\Users\Administrator\Desktop\from\from.ino:5:
C:\Users\Administrator\Documents\Arduino\libraries\ESPAsyncWebServer-master\src/ESPAsyncWebServer.h:63:3: note: previous declaration 'WebRequestMethod HTTP_POST'
 63 | HTTP_POST = 0b00000010,
 | ^~~~~~~~~
In file included from C:\Users\Administrator\Documents\Arduino\libraries\WiFiManager/WiFiManager.h:17,
 from C:\Users\Administrator\Desktop\from\from.ino:6:
C:\Users\Administrator\AppData\Local\Arduino15\packages\esp8266\hardware\esp82663円.0.2\libraries\ESP8266WebServer\src/ESP8266WebServer.h:47:61: error: 'HTTP_PUT' conflicts with a previous declaration
 47 | enum HTTPMethod { HTTP_ANY, HTTP_GET, HTTP_HEAD, HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_DELETE, HTTP_OPTIONS };
 | ^~~~~~~~
In file included from C:\Users\Administrator\Desktop\from\from.ino:5:
C:\Users\Administrator\Documents\Arduino\libraries\ESPAsyncWebServer-master\src/ESPAsyncWebServer.h:65:3: note: previous declaration 'WebRequestMethod HTTP_PUT'
 65 | HTTP_PUT = 0b00001000,
 | ^~~~~~~~
In file included from C:\Users\Administrator\Documents\Arduino\libraries\WiFiManager/WiFiManager.h:17,
 from C:\Users\Administrator\Desktop\from\from.ino:6:
C:\Users\Administrator\AppData\Local\Arduino15\packages\esp8266\hardware\esp82663円.0.2\libraries\ESP8266WebServer\src/ESP8266WebServer.h:47:71: error: 'HTTP_PATCH' conflicts with a previous declaration
 47 | enum HTTPMethod { HTTP_ANY, HTTP_GET, HTTP_HEAD, HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_DELETE, HTTP_OPTIONS };
 | ^~~~~~~~~~
In file included from C:\Users\Administrator\Desktop\from\from.ino:5:
C:\Users\Administrator\Documents\Arduino\libraries\ESPAsyncWebServer-master\src/ESPAsyncWebServer.h:66:3: note: previous declaration 'WebRequestMethod HTTP_PATCH'
 66 | HTTP_PATCH = 0b00010000,
 | ^~~~~~~~~~
In file included from C:\Users\Administrator\Documents\Arduino\libraries\WiFiManager/WiFiManager.h:17,
 from C:\Users\Administrator\Desktop\from\from.ino:6:
C:\Users\Administrator\AppData\Local\Arduino15\packages\esp8266\hardware\esp82663円.0.2\libraries\ESP8266WebServer\src/ESP8266WebServer.h:47:83: error: 'HTTP_DELETE' conflicts with a previous declaration
 47 | enum HTTPMethod { HTTP_ANY, HTTP_GET, HTTP_HEAD, HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_DELETE, HTTP_OPTIONS };
 | ^~~~~~~~~~~
In file included from C:\Users\Administrator\Desktop\from\from.ino:5:
C:\Users\Administrator\Documents\Arduino\libraries\ESPAsyncWebServer-master\src/ESPAsyncWebServer.h:64:3: note: previous declaration 'WebRequestMethod HTTP_DELETE'
 64 | HTTP_DELETE = 0b00000100,
 | ^~~~~~~~~~~
In file included from C:\Users\Administrator\Documents\Arduino\libraries\WiFiManager/WiFiManager.h:17,
 from C:\Users\Administrator\Desktop\from\from.ino:6:
C:\Users\Administrator\AppData\Local\Arduino15\packages\esp8266\hardware\esp82663円.0.2\libraries\ESP8266WebServer\src/ESP8266WebServer.h:47:96: error: 'HTTP_OPTIONS' conflicts with a previous declaration
 47 | enum HTTPMethod { HTTP_ANY, HTTP_GET, HTTP_HEAD, HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_DELETE, HTTP_OPTIONS };
 | ^~~~~~~~~~~~
In file included from C:\Users\Administrator\Desktop\from\from.ino:5:
C:\Users\Administrator\Documents\Arduino\libraries\ESPAsyncWebServer-master\src/ESPAsyncWebServer.h:68:3: note: previous declaration 'WebRequestMethod HTTP_OPTIONS'
 68 | HTTP_OPTIONS = 0b01000000,
 | ^~~~~~~~~~~~
exit status 1
Error compiling for board LOLIN(WeMos) D1 R1.

Here is my code:

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <WiFiManager.h>
AsyncWebServer server(80);
const char* PARAM_INPUT_1 = "input1";
const char* PARAM_INPUT_2 = "input2";
const char* PARAM_INPUT_3 = "input3";
const char index_html[] PROGMEM = R"rawliteral(
<!DOCTYPE HTML><html><head>
 <title>ESP Input Form</title>
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}
 .button { background-color: #195B6A; border: none; color: white; padding: 16px 40px;
 text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}
 .button2 {background-color: #195B6A;}</style>
 </head><body>
 <form action="/get">
 input1: <input type="text" name="input1" style="background-color: #195B6A; border: none; color: white; padding: 16px 40px;
 text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;">
 <input type="submit" value="Submit">
 </form><br>
 <form action="/get">
 input2: <input type="text" name="input2">
 <input type="submit" value="Submit">
 </form><br>
 <form action="/get">
 input3: <input type="text" name="input3">
 <input type="submit" value="Submit">
 </form>
 <h1>SmartHomeHarris-CoLTD</h1>
 <p>GPIO 1 - State off</p>
 <p><a href="/1/on"><button class="button">ON</button></a></p>
 <p>GPIO 2 - State off</p>
 <p><a href="/2/on"><button class="button">ON</button></a></p>
 <p>GPIO 3 - State off</p>
 <p><a href="/3/on"><button class="button">ON</button></a></p>
 <p>GPIO 4 - State off</p>
 <p><a href="/4/on"><button class="button">ON</button></a></p>
 </body></html>)rawliteral";
void notFound(AsyncWebServerRequest *request) {
 request->send(404, "text/plain", "Not found");
}
void setup() {
 Serial.begin(115200);
 WiFi.mode(WIFI_STA);
 WiFiManager wm;
 if (WiFi.waitForConnectResult() != WL_CONNECTED) {
 Serial.println("WiFi Failed!");
 return;
 }
 bool res;
 // res = wm.autoConnect(); // auto generated AP name from chipid
 // res = wm.autoConnect("AutoConnectAP"); // anonymous ap
 res = wm.autoConnect("AutoConnectAP","password"); // password protected ap
 if (!res) {
 Serial.println("Failed to connect");
 // ESP.restart();
 } 
 else {
 // if you get here you have connected to the WiFi 
 Serial.println("connected...yeey :)");
 }
 Serial.println();
 Serial.print("IP Address: ");
 Serial.println(WiFi.localIP());
 // Send web page with input fields to client
 server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
 request->send_P(200, "text/html", index_html);
 });
 // Send a GET request to <ESP_IP>/get?input1=<inputMessage>
 server.on("/get", HTTP_GET, [] (AsyncWebServerRequest *request) {
 String inputMessage;
 String inputParam;
 // GET input1 value on <ESP_IP>/get?input1=<inputMessage>
 if (request->hasParam(PARAM_INPUT_1)) {
 inputMessage = request->getParam(PARAM_INPUT_1)->value();
 inputParam = PARAM_INPUT_1;
 }
 // GET input2 value on <ESP_IP>/get?input2=<inputMessage>
 else if (request->hasParam(PARAM_INPUT_2)) {
 inputMessage = request->getParam(PARAM_INPUT_2)->value();
 inputParam = PARAM_INPUT_2;
 }
 // GET input3 value on <ESP_IP>/get?input3=<inputMessage>
 else if (request->hasParam(PARAM_INPUT_3)) {
 inputMessage = request->getParam(PARAM_INPUT_3)->value();
 inputParam = PARAM_INPUT_3;
 }
 else {
 inputMessage = "No message sent";
 inputParam = "none";
 }
 Serial.println(inputMessage);
 request->send(200, "text/html", "HTTP GET request sent to your ESP on input field (" 
 + inputParam + ") with value: " + inputMessage +
 "<br><a href=\"/\">Return to Home Page</a>");
 });
 server.onNotFound(notFound);
 server.begin();
}
void loop() {
 
}

I tried different version of WiFiManager but still it doesn't work.

ocrdu
1,7953 gold badges12 silver badges24 bronze badges
asked Jul 26, 2022 at 6:18
2
  • 1
    WiFiManager uses the ESP8266WebServer library and you want to use the async version of it. The conflict is between very similar source codes of the two web server libraries. here is an async version of WiFiManager github.com/khoih-prog/ESPAsync_WiFiManager . I don't know if it is good Commented Jul 26, 2022 at 6:48
  • I have the same issue. THe program used to work. I recently tried to modify the router wifi settings and I get these errors. Commented May 9, 2024 at 20:46

1 Answer 1

1

As the error messages tell you, there are two declarations of HTTP_OPTIONS via two includes. Apparently you cannot use these at the same time.

"WiFiManager.h" has the enum HTTPMethod that has these constants.

And "ESPAsyncWebServer.h" has another declaration of the same constants.

You might need to read their documentation to learn whether work-arounds are possible.

answered Jul 26, 2022 at 6:31

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.