How to get mDNS working with ESP-IDF v5

Since ESP-IDF v5, mDNS has been moved from built-in library to component library.
I need to use the following command to install it.
This works fine in VSC using Espressifs ESP-IDF extension…

idf.py add-dependency “espressif/mdns^1.0.7”

Since we dont have idf.py to use, how do we do it ?

1 Like

I have exactly the same issue, couldn’t figure out how to solve it yet.

@valeros, please help

I believe it’s still a generic IDF component, so the instructions here should be relevant. In a nutshell, create a new folder components in the root of your project (near platformio.ini) and copy the mdns component to that folder directly from the repository esp-protocols/components/mdns at master · espressif/esp-protocols · GitHub

1 Like

Just tried it, and could not get it to compile.
Maybe you can create a new project and give it a try.
Be sure to use platform = espressif32@6.0.0, if you do it.

Mind sharing the error message or maybe a simple project to reproduce the problem?

Well…
I get very strange behavior when having two versions of IDF on both my system at home and at work.
Using platform = espressif32@5.3.0 and platform = espressif32@6.0.0
Most of the time it causes compile issues for new projects. When it does this the only solution I have found is to delete my .platformio folder and start again.

Anyways… I just tired that and now it compiles.

1 Like

Just an update for anyone in the future. I’m using platform = espressif32@6.3.2 in my platform.ini

Create idf_component.yml in your src/ directory (IMPORTANT: it must be in src, not in your project home!). Do a full clean and build. The internal idf system will pull the components for you (Running `idf.py reconfigure` from PlatformIO · Issue #1157 · platformio/platform-espressif32 · GitHub). After doing a build, it’ll add a managed_compoments/ directory, which I added to my .gitignore.

My idf_component.yml looks like:

dependencies:
  idf: ">=5.0"
  espressif/mdns: ">=1.2.0"
1 Like

mDNS was removed from ESP-IDF 5.0
You can add it manually by running the following command in the terminal idf.py add-dependency espressif/mdns

https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/protocols/mdns.html