I have a micro-controller,ESP8266 for the moment, which is connecting to a mqtt broker and pulish some messages. I have configured mqtt broker on raspberry pi which has an IP address so for now I have hard coded the mqtt broker IP in micro-controller firmware. But I want it like it search the mqtt server in local network and then connect to the same.

so is it possible to do the same ?? Does such micro-controller can have that capability to do so? I have already search a lot on Google but does not found any solution. Please provide some path.

Thanks Abhishek

2 Answers 2


The correct response to this is DNS with different versions for LAN and public Internet.

For finding devices on the local network you want to use the mDNS (also known as Avahi or Bonjour) and you want to publish your broker using the _mqtt._tcp service.

Setting up Avahi on the Raspberry pi to publish the service is relatively simple, and there are mDNS libraries for Arduino to do the lookup.

Likewise for finding a public MQTT broker on the Internet for a given organisation they should publish their broker details using a service record (SRV) e.g. example.com would publish the SRV record at _mqtt._tcp.example.com


Although I have accepted @hardillb answer. But I am writing this answer to share the another approach that I came across when researching around this.

Ok so idea is to use IP Broadcasting. So what I have done is, my edge device is continuously emitting an UDP messages over broadcast IP that contains the itself IP. The micro-controller ESP listen to UDP messages and extract IP from that and connect to it.

So advantage is that if I have more then one edge device is in system, it is easy to allocate different edge to UC at run time.That keeps the load balancing too.


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.