mDNS lookup in micropython?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
spierepf
Posts: 22
Joined: Mon Jul 08, 2019 3:22 pm

mDNS lookup in micropython?

Post by spierepf » Tue Oct 12, 2021 12:45 am

I've got a raspberry pi zero hosting an eclipse-mosquitto MQTT server with a number of LOLIN D1 mini Pros running as clients.

Right now, those clients have the ip address of the pi hardcoded, which is less than ideal in case DHCP deciides to eat my lunch.

My laptop can resolve the pi's address using mDNS (raspberrypi.local), but I cannot achieve the same thing using micropython:

Code: Select all

>>> import socket
>>> print(socket.getaddrinfo('raspberrypi.local', 80))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: -2
Do I need a specific library in order to resolve mDNS lookups?

Post Reply