The goal
I am trying to use mDNS as a means to obtain the IP address of an ESP32 webserver. (ESP32 Wroom32D using board = esp32doit-devkit-v1)
The problem
I can ping the microcontroller by its IP address, but cannot ping the microcontroller by its mDNS name. Windows 10 and Ubuntu terminal returns:
Ping request could not find host esp32. Please check the name and try again. I also cannot access http://esp32.local/hello as would be expected failing the ping test
The code:
#include <Arduino.h>
#include <ESPmDNS.h>
#include <ESPAsyncWebServer.h>
const char* ssid = "my_ssid";
const char* password = "my_password";
AsyncWebServer server(80);
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi..");
}
if(!MDNS.begin("esp32")) {
Serial.println("Error starting mDNS");
return;
}
Serial.println(WiFi.localIP());
server.on("/hello", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(200, "text/plain", "Hello World");
});
server.begin();
}
void loop(){}
Libraries
- ESPAsyncWebServer library: https://github.com/me-no-dev/ESPAsyncWebServer
- AsyncTCP library: https://github.com/me-no-dev/AsyncTCP
Can anyone give some indication of how to debug or resolve this issue?
Thank you