ESP32 network discovery through mDNS with MicroPython

Coming from Investigating ESP32 WiFi connectivity behavior, we are investigating and discussing mDNS support for Pycom MicroPython here.

Dear @roh,

This would be cool and I was thinking about that as well. However, I haven’t been able to see anything at espressif.local out of the box. May we missed some switch – research+outcome welcome! But I’m also hesitant: While having no proof for that, I am questioning if a superfast cycle like you’ve outlined with

will be able to let mdns or similar technologies enough breath to converge. Everything I can tell you from my experiments is that reaching the device using the regular espressif hostname through a standard Fritz DNSDHCP is not reliable at all regarding quick turnaround times which I believe are essential for plug & play operations.

However, as soon as the device will be in maintenance mode, we will be happy to use just everything from the comfort zone the ESP32 might be able to offer us. I’ve somewhere read something about someone trying to do some DLNA stuff on the ESP32 – maybe with MicroPython already. Finding this again might give us some direction to follow.

Thanks for your interest, I would be happy to have you with us close to this specific topic (ongoing), especially reviewing the first important iterations of the respective implementation.

Cheers,
Andreas.

It’s been this thread (without any solution fitting our current problem) on the MicroPython forum:

Interesting enough, it’s Daniel Campora who is answering back then. So, maybe we could use that to ask him on the Pycom forum these days.

We want to a) look at MicroPython in general but also currently more important to us b) at the Pycom implementation specifically.

It looks like it has been on someones wishlist already:

Features wish list | Pycom user forum

First, as I learned

I would like to retract that statement:


Then again,


hard-coding IPs, or scanning ports sucks

RFC: mDNS support implementation · Issue #201 · micropython/micropython-esp32 · GitHub

So true.

Discussions

Candidates

See also

Why can’t I just ping this widget?

MAC address resolution · ... and another thing ...

This is just suitable for the CC3100, as far as we can deduce from Repository search results · GitHub.

At least, it’s not a builtin on Pycom’s MicroPython:

make repl
>>> import network
>>> dir(network)
['__class__', '__name__', 'Bluetooth', 'LTE', 'LoRa', 'Server', 'Sigfox', 'WLAN']

Bummer.

@vinz is already using the MicroDNSSrv [1] at the Hiverize Datalogger for FiPy [2]. I am wondering if this might also help us for device discovery in any way? Probably not.

[1] GitHub - jczic/MicroDNSSrv: A micro DNS server for MicroPython to simply respond to A queries on multi-domains with or without wildcards (used on Pycom modules & ESP32)
[2] FiPy/webserver.py at workshop-20190528 · Hiverize/FiPy · GitHub

Two more things for today:

If I’m not counting wrong here, the issue at [ESP32] DHCP Hostname not working correctly · Issue #4748 · micropython/micropython · GitHub seems to reflect that well.


So, we will be happy to check out mDNS capability by goatchurchprime · Pull Request #14 · peterhinch/micropython-mqtt · GitHub within one of the next iterations on the datalogger code.

Thanks again for bringing this up, @roh.

There have been some news about this within the development of Genuine MicroPython coming from the https://github.com/micropython/micropython/issues/4821.

It looks like the most recent Pycom firmware release 1.20.1.r3 available through GitHub - pycom/pycom-micropython-sigfox at Release/v1.20 adds mDNS support per

cc @roh

This thread seems to be the default one on Google when you search “micropython mdns”.

That’s why I also wanted to put a reference to an uasyncio implementation for MDNS service discovery here: GitHub - cbrand/micropython-mdns: MDNS implementation for MicroPython with Service Discovery

This library has been tested on the ESP32 with MicroPython 1.13 and worked on a rather chatty network with a lot of mdns service announcements (mainly generated via queries with the tool mdns-scan).

2 Likes

Thank you so much for conceiving and sharing this, Christoph!

1 Like