smacaluso
smacaluso

Reputation: 60

How to find PC local IP from ESP32 to use MQTT nodejs server

I am working on a project and I need all my ESP32s to communicate with my PC to relay information. I am developing my MQTT server and I would need a way to find the IP of the PC which hosts the MQTT server to be able to send it the data from the ESP32.

Long time ago I tried to deal with NetBIOS broadcast but it's really unstable and complex to code in Arduino C++.

Upvotes: 1

Views: 353

Answers (2)

ocrdu
ocrdu

Reputation: 2183

If you can't get mDNS to work, and if you have full control of the LAN's router: some routers can act both as a DNS proxy and as a LAN DNS server, see here for example.

You can then connect by name or get the IP address without further configuration of the ESP32 (unless you change the server name, of course). It won't show you directly if the _mqtt._tcp service is available, though.

Upvotes: 0

hardillb
hardillb

Reputation: 59751

mDNS is what you are looking for.

The correct service type for MQTT is _mqtt._tcp.

There are plenty of libraries that support publishing mDNS services such as Avahi on Linux.

Windows doesn't support mDNS as a client but iirc you can install the Apple printer driver kit to add support.

Upvotes: 4

Related Questions