-
Notifications
You must be signed in to change notification settings - Fork 7.6k
WiFi.setHostname() not working #6278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
how did you test this? it's often that the DHCP server might cache the hostname |
@me-no-dev I power cycled the Wi-Fi router that provides the DHCP server several times, power cycled the esp32 several times, but the hostname I see on the router is always esp32-XXXXXX |
On most routers if you want to clear the cache, you have to reset it using the reset button... and not just power cycle it. You could... connect to a different router, or reset the router, or change the esp32 MAC address to confirm the hostname shows up in the router. |
I have mikrotiks here for routers and they have "clear leases" option that allowed me to confirm the hostname change, else I also thought it did not work. |
Interesting that even if I change the MAC address, the IP address I've got from the DHCP is different, but the hostname I see on the router is still the same esp32-XXXXXX. @me-no-dev could you please share your relevant code lines, this is in my running sketch (including the MAC address change I applied now for testing):
|
Apparently WiFi.setHostname should be called before setting WiFi.mode in order to work. |
Thank you @gonzabrusco it works!
|
Wouldn't it be super if the all the WiFi call setting sequences were documented somewhere... 😉 |
See espressif/arduino-esp32#6278, setHostname needs to be called before setting the wifi mode cause otherwise it will not / not always be set correctly
Board
ESP32
Device Description
plain module
Hardware Configuration
N/A
Version
latest master
IDE Name
Arduino IDE
Operating System
macOS 12.1
Flash frequency
40Mhz
PSRAM enabled
no
Upload speed
115200
Description
WiFi.setHostname() does not work, hostname remain always esp32-XXXXXX
Sketch
Debug Message
Other Steps to Reproduce
WiFi.setHostname("hostname");
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: