I have a number of ESP8266 weather loggers running and recently have implemented WiFiMulti in my latest project.
https://github.com/wt29/anemometer
also https://www.instructables.com/Anemomete ... t-Logging/
My issue is I have a number of devices on my local network and the hostname only every appears as ESP-XXXXX in my DHCP server whereas it works fine for my "normal" WiFi connect. It's not that important but I'm curious as to how to fix it. My "ordinary" logger (temp/humidity/pressure) is at
https://github.com/wt29/IoTTemp_basic
Code for the WiFiMulti (anemometer) is
void connectWiFi() {
#ifdef STATIC_IP
WiFi.config( staticIP, gateway, subnet, dns1 );
#endif
WiFi.hostname( nodeName ); // This will show up in your DHCP server
while (wifiMulti.run() != WL_CONNECTED) {
startWiFi = millis() ; // When we started waiting
while ((WiFi.status() != WL_CONNECTED) && ( (millis() - startWiFi) < waitForWiFi ))
{
delay(500);
Serial.print(".");
}
}
Code for the working (temp/humidity etc is
void connectWiFi() {
#ifdef STATIC_IP
WiFi.config( staticIP, gateway, subnet, dns1 );
#endif
WiFi.begin(ssid, password);
WiFi.hostname( nodeName ); // This will show up in your DHCP server
startWiFi = millis() ; // When we started waiting
// Loop and wait
while ((WiFi.status() != WL_CONNECTED) && ( (millis() - startWiFi) < waitForWiFi ))
{
Be grateful for any advice
/Tony