2

I am using the AT command binary (provided by Espresif) to interface my wi-fi application. In order to identify the device over a network, I've changed the Hostname to a known name, but when I scan the network, the Hostname still being "Espressif", instead of being my "Own Hostname".

Does anyone knows how to fix that? I actually think that it's an error on AT command's binary.

asked Feb 27, 2019 at 14:43

4 Answers 4

1

I've got the same issue.

Code looks like:

#include <Arduino.h>
#include "WiFi.h"
void setup() {
 // Start the Wifi connection ...
 WiFi.enableSTA(true);
 WiFi.begin(ssid, password);
 // TODO Hostname setting does not work. Always shows up as "espressif"
 if(WiFi.setHostname("myHostname")) {
 Serial.printf("\nHostname set!\n");
 } else {
 Serial.printf("\nHostname NOT set!\n");
 }
}
answered Jun 13, 2019 at 4:56
Sign up to request clarification or add additional context in comments.

1 Comment

I'm not saying its ok, I think it's pretty crappy, just confirming your issue. Its the same for me.
1

After literally more than 10 hours of research, trying to pinpoint, analyze and/or fix the issue one way or another, I gave up and accepted the workaround. You can find it here.

In short, what I do and what works for me is:

WiFi.disconnect();
WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE); // This is a MUST!
if (!WiFi.setHostname("myFancyESP32")) {
 Serial.println("Hostname failed to configure");
}
WiFi.begin(ssid, password);

This is really frustrating but for the time being it seems that the issue comes from the ESP IDF and unless it is fixed there, it will not work.

answered Nov 29, 2020 at 19:44

1 Comment

Any updates on this ? Because this workaround doesn't work for me.
1

There is a bug in the Espressif code. The workaround is to reset the WIFI before setting hostname and starting the WIFI:

WiFi.disconnect(true);
WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE); 
WiFi.setHostname(hostname);

Also note that the OTA may make the issue even harder to fix. If using MDSN and OTA, please add the following code (after the WIFI-stuff) to ensure that the hostname gets correlcty set:

MDNS.begin(hostname);
ArduinoOTA.setHostname(hostname);
ArduinoOTA.begin();

For details, please read the issue 2537 in the Espressif GitHub repo.

answered Mar 19, 2021 at 10:36

Comments

0

Try to wait for Wifi to set-up. easiest (never the best) way with Delay(150).

answered Oct 15, 2019 at 14:29

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.