Set hostname on the ESP8266 on diyBMS

Hey,
i know i could theoretically set the hostname of the ESP by editing the source code but it would be nicer to have an option in the settings. Did i overlook an option?

The hostname should be set by the code already…

SERIAL_DEBUG.println(“Connecting to Wi-Fi…”);

#if defined(ESP8266)

WiFi.hostname(“diyBMS-ESP8266”);

#endif

#if defined(ESP32)

WiFi.setHostname(“diyBMS-ESP32”);

#endif

WiFi.mode(WIFI_STA);

WiFi.begin(DIYBMSSoftAP::WifiSSID(), DIYBMSSoftAP::WifiPassword());

Hmmm. ok.
Mine shows up as ESP-7FA5AF.

Yes - so does mine!!

Perhaps its an issue with the ESP firmware/base libraries?

It’s likely a bug in how you are calling setHostname(). make sure you call this after initializing wifi otherwise it may silently be dropped.

Looking at this bug, seems like a lot of people have the same problem.

The hostname should be set BEFORE calling wifi.begin() - its only if you are using the “mdns” library that you set that after the begin.

Although another bug refers to using “-” in the hostname which I was, I’ll try swapping that to an underscore.

At least on the esp32 it needs to be after calling at least WiFi.mode(). Is there a similar call for the esp8266?

Yes, I’ll try and see what happens.

1 Like