Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By dunk
#24821 while searching for the solution i found examples that allow the ESP8266 to become an mDNS Responder eg: https://github.com/esp8266/Arduino/blob/esp8266/hardware/esp8266com/esp8266/libraries/ESP8266mDNS/examples/mDNS_Web_Server/mDNS_Web_Server.ino
but nowhere could i find code that allowed me to Discover mDNS Services on the network.

so i wrote this little library over the last week or two:
https://github.com/mrdunk/esp8266_mdns
it's my first time playing with the Arduino environment so please forgive any deviations from accepted Arduino coding style.

there are examples for the following included:
1. https://github.com/mrdunk/esp8266_mdns/ ... simple.ino displays *all* mDNS data received by the ESP8266.
2. https://github.com/mrdunk/esp8266_mdns/ ... s_test.ino sends an mDNS Question requesting the _mqtt._tcp.local service and returns the ipv4 network address of all hosts providing this service.

the library could be used as the starting point for any project that needs access to raw mDNS data.
User avatar
By dunk
#40555 after trying to find this post again via search engine i discovered i'm missing some pertinent search terms in the text...
this post is relevant to anyone who is trying to create an mDNS client or Bonjour client.

my use case involves running an MQTT (mosquitto) broker on another embedded machine and advertising it's presence via mDNS (Avahi) to achieve my goal of zero configuration of the esp8266.
the Arduino code posted above will allow the esp8266 to discover the Brokers location via mDNS.

apologies for the blatant keyword stuffing in the above paragraph.
User avatar
By Arunk3001
#41424 I'm trying to use this library to discover and connect to an MQTT server, but I'm having difficulty understanding how to get an IP address out of a request. The server is responding to server.local when queried from browser, but I can't connect "server.local" to an IP address in the ESP. When I run the simple example I can see the server responding to mDNS queries with an IP, but I can't seem to find my way beyond that. Any advice as far as where to look to get started?