The mDNS Browser lets you see wireless Arduino devices advertising services on your local network. It helps you make a TCP Client connection to devices — such as an ESP8266 — by name.

mDNS browser

MegunoLink’s mDNS browser lets you see devices advertising services on your local network

What is mDNS?

mDNS, or multicast DNS, is a service that helps you find your wireless Arduino devices on the network without knowing their IP address. It is a standard protocol widely implemented for local printer discovery, wireless speakers, network storage devices etc. mDNS won’t let you find devices any where on the Internet, but mDNS can help if your sensor and computer are on the same local network.

Find your ESP32/ESP8266

Check out our walk-through on finding an ESP32/ES8266 using mDNS, then look up plotting and building interfaces once you find it.

mDNS support is built-into MegunoLink

MegunoLink contains a simple mDNS client (so it doesn’t require any external services such as Bonjour). The mDNS client periodically looks for devices on your network which advertise the services you are interested in. A service, is simply a named port that your Arduino program opens to communicate with the outside world. The Arduino advertises the name of the port using a MDNS library, such as the ESP8266mDNS library for the ESP8266 WiFi module.

Each device can advertise many service end-points and many devices may advertise the same type of end-point. Each device should have a unique name, so you can choose the one you want to connect to. In MegunoLink, you’ll select your connection by the type of service and the name of the device.

Using the mDNS Browser

Open the mDNS Browser by selecting mDNS Configuration from MegunoLink’s gear menu. You can use the Start and Stop buttons to start and stop the mDNS client.

Click the Edit button to show the Manage Services window to setup the services you are interested in (you’ll need to stop the mDNS client first if it is running). Click the New to add a service name, Edit to change an existing name or Delete to remove an entry from the list. Enter the end-point of the service (see below). MegunoLink will search for devices advertising any service in the list.

Manage mDNS services

Select the mDNS services that MegunoLink should search for.

Advertising your Arduino using mDNS

Your Arduino program needs to advertise its services so they can be found by mDNS clients. For mDNS, a service is a name, protocol and port number. The client trying to connect to your program will use this information to resolve the Arduino’s IP address and open the connection.

The ESP8266 tool-chain for Arduino includes a compatible mDNS server. To use this server, you’ll need to

  1. include ESP8266mDNS.h, start the mDNS server and register the service,
  2. Call MDNS.begin("name"); to start the server. Here, name is the name that will identify your device on the network, so it should be unique. The example below creates a unique name by appending the chip id to the program name using the custom function MakeMine(…).
  3. Call MDNS.addService("service-id", "protocol", port); to advertise the service. The service end-point will be advertised as _service-id._protocol. For example, if you call MDNS.addService("n8i-mlp", "tcp", 23); in your Arduino program, the end-point will be named _n8i-mlp._tcp. Add the end-point to MegunoLink’s list of services so it will find your device.

Figuring out the Service End-Point for the mDNS Browser

The Service end-point is the full name of the service. Services are registered with a service-id and protocol. Join the two together to create the end-point name.

So if your service id is n8i-mlp and the protocol is tcp, the end-point’s full name is: _n8i-mlp._tcp.

You might see .local added to the end-point in some mDNS browsers. MegunoLink’s library adds that automatically so you shouldn’t enter it when adding a service to MegunoLink.

mDNS Example for ESP8266

This example for an ESP8266 registers a service end-point named _n8i-mlp._tcp on port 23. Any data received on the Arduino’s serial port is sent to connected TCP clients. Any data received from a TCP client is sent out the serial port.

You can find this example in MegunoLink by clicking Library Examples → MegunoLink → Other → mDNSExample

Here’s a screen shot from MegunoLink showing a serial and TCP connection to an ESP8266 device. Messages sent to the serial port are relayed back via a TCP connection and vice versa.

mDNS Browser example

Screen shot from MegunoLink showing TCP and serial communication

Start typing and press Enter to search