Chat freely about anything...

User avatar
By avoletta
#66193 Hi all,

Need same help. The problem is:

The user needs to access a webserver web page installed on esp8266 and connected as a client.

For this it is necessary to know the IP assigned by the DHCP of the network router.

I'm trying to use the mDNS library to access the device as "mydevice.local".

This is not working. (Even using Bonjour on Win 10, and also does not work on Android 6.0)

Does anyone suggest another technique or method to achieve for the same purpose?

Tks!
User avatar
By sfranzyshen
#66269
avoletta wrote:Hi all,

Does anyone suggest another technique or method to achieve for the same purpose?

Tks!


If you are using a common wifi router to connect your devices and the router handles making dns entries for dhcp hostnames then simply by adding a hostname to your dhcp request will allow any computer, phone, tablet to resolve the name given by using regular dns ... example:
Code: Select all 
  // Setup variables
  const char* ssid = "SSID"; // case sensitive
  const char* password = "PASSWORD"; // case sensitive
  const char* MyHostname = "MYNAME"; // not case sensitive

  WiFi.mode(WIFI_STA); // We set to station mode only (STA, STA_AP, AP)
  WiFi.hostname(MyHostname); // Set the dhcp hostname (if your router supports it)
  delay(500);
  WiFi.begin(ssid, password); // Start WiFi

of course your router will need to support this ... handling both the dhcp server and the forwarding dns server ... most modern routers do this!