mDNS not working
marcolino7 opened this issue · 1 comments
marcolino7 commented
Hi,
I am trying to configure and make it work mDNS responder in order to make configuration more simple.
Looking at varius code around online I found this code
WiFi.hostname("bigclock");
if (MDNS.begin("bigclock")) { // Start the mDNS responder for esp8266.local
MDNS.addService("http", "tcp",80);
Serial.println("mDNS responder started");
}
Serial message was on console so MDNS.begin executed succefully.
I tried to add before or after WiFiManager.begin(configManager.data.projectName);
but it does not work.
Anyone get mDNS work?
Marco
maakbaas commented
This adapted example works for me. Maybe you forgot the MDNS update function in your loop? In any case, I have also found that finding MDNS devices can be a bit hit or miss, even when your ESP8266 is configured correctly.
#include <Arduino.h>
#include "LittleFS.h"
#include "WiFiManager.h"
#include "webServer.h"
#include "updater.h"
#include "fetch.h"
#include "configManager.h"
#include "timeSync.h"
#include "ESP8266mDNS.h"
void setup()
{
Serial.begin(115200);
LittleFS.begin();
GUI.begin();
configManager.begin();
WiFiManager.begin(configManager.data.projectName);
timeSync.begin();
MDNS.begin("esptest");
MDNS.addService("http", "tcp", 80);
Serial.println("Hello world");
}
void loop()
{
//software interrupts
WiFiManager.loop();
updater.loop();
configManager.loop();
//your code here
MDNS.update();
}