-->
Page 1 of 1

WiFiMulti hostname

PostPosted: Sat Sep 18, 2021 11:28 pm
by wt29
Hi All,

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
Code: Select allvoid 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

Code: Select allvoid 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

Re: WiFiMulti hostname

PostPosted: Thu Sep 23, 2021 12:31 pm
by prgvitor
wt29 wrote:Hi All,

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
Code: Select allvoid 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

Code: Select allvoid 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



I'm not used to using arduino libraries since I program ARM microcontrollers. One suggestion is to try AT commands directly over the USART. It's more practical and Espressif has a lot of documentation, including examples.

You can use the command "AT+CWHOSTNAME="my_station". Don't forget to check the BaudRate and insert "\r\n" at the end of the message. This command only needs to be executed once and the name is saved in Flash. You should get "OK" in response, so after sending the command read the input serial data and print to see if the change was made.

Thanks

Re: WiFiMulti hostname

PostPosted: Fri Sep 24, 2021 3:27 am
by QuickFix
prgvitor wrote:One suggestion is to try AT commands directly over the USART. It's more practical and Espressif has a lot of documentation, including examples.

Really? You're joking right? :?