So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By KDB
#68711
martinayotte wrote:Are you doing the WiFi.hostname("ESP3") before doing the calls to WiFi.mode(WIFI_STA); and WiFi.begin(ssid, password); ?

For me, it is working fine, notice the name I've choose still contains end of MAC, but this is what I want :

Code: Select allMyESPAP-192B86   192.168.0.101   60:01:94:19:2b:86   23 Hours 55 Minutes


About DNS, as I said earlier, most routers doesn't take care of adding new hostnames, you need to use mDNS with Bonjour to make that work, like mine above with "ping MyESPAP-192B86.local" .


I did it behind WiFi.begin . Will try before . Klaus-Dieter
User avatar
By KDB
#69083
KDB wrote:
martinayotte wrote:What do you mean "not working" ?

Does your router shows that ESP3 hostname in the IP leases list ?

Don't expect to be able to do "ping ESP3", it won't work since the DNS doesn't know this hostname.
Use mDNS service on your ESP, install Bonjour on Windows, and then "ESP3.local" will be resolved.


The router shows other names. Esp Server and the dns name is ESPxxxxxx. xxxxxx is the end of the mac adress

Hello martinayotte !
I tested many Versions of Setting the hostname. I succeeded only with ESP_xxxxxx where xxxxx is the end of the Mac adress. Did you ever tested other names ?
Thank you
Klaus-Dieter
User avatar
By martinayotte
#69087 Here is my code from setup() :

Code: Select all  char HostName[32];
  sprintf(HostName, "MyESPAP-%06X", ESP.getChipId());
  Serial.printf("\nHello from %s !\r\n", HostName);
  wifi_station_set_hostname(HostName);
  WiFi.softAP(HostName, password);
  WiFi.mode(WIFI_AP_STA);


And here is what "avahi-browse -ar | grep -i esp" is showing on Linux :

Code: Select all+   eth0 IPv4 MyESPAP-1926C8                                _arduino._tcp        local
=   eth0 IPv4 MyESPAP-1926C8                                _arduino._tcp        local
   hostname = [myespap-1926c8.local]
   txt = ["auth_upload=no" "board=ESP8266_WEMOS_D1MINI" "ssh_upload=no" "tcp_check=no"]
+   eth0 IPv4 MyESPAP-1926C8                                Web Site             local
=   eth0 IPv4 MyESPAP-1926C8                                Web Site             local
   hostname = [myespap-1926c8.local]
+   eth0 IPv4 MyESPAP-1926C8                                Telnet Remote Terminal local
=   eth0 IPv4 MyESPAP-1926C8                                Telnet Remote Terminal local
   hostname = [myespap-1926c8.local]


As you can see, the hostname is really ending up to be "myespap-1926c8.local"
User avatar
By KDB
#69089 Thank you. Did. you ever test a name witout getChipId ?

martinayotte wrote:Here is my code from setup() :

Code: Select all  char HostName[32];
  sprintf(HostName, "MyESPAP-%06X", ESP.getChipId());
  Serial.printf("\nHello from %s !\r\n", HostName);
  wifi_station_set_hostname(HostName);
  WiFi.softAP(HostName, password);
  WiFi.mode(WIFI_AP_STA);




And here is what "avahi-browse -ar | grep -i esp" is showing on Linux :

Code: Select all+   eth0 IPv4 MyESPAP-1926C8                                _arduino._tcp        local
=   eth0 IPv4 MyESPAP-1926C8                                _arduino._tcp        local
   hostname = [myespap-1926c8.local]
   txt = ["auth_upload=no" "board=ESP8266_WEMOS_D1MINI" "ssh_upload=no" "tcp_check=no"]
+   eth0 IPv4 MyESPAP-1926C8                                Web Site             local
=   eth0 IPv4 MyESPAP-1926C8                                Web Site             local
   hostname = [myespap-1926c8.local]
+   eth0 IPv4 MyESPAP-1926C8                                Telnet Remote Terminal local
=   eth0 IPv4 MyESPAP-1926C8                                Telnet Remote Terminal local
   hostname = [myespap-1926c8.local]


As you can see, the hostname is really ending up to be "myespap-1926c8.local"