🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    WiFi.setHostname("Name"); not working (Core Basic)

    Arduino
    2
    5
    5.3k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      Stoni99
      last edited by

      I don't get an error message from the compiler, but the new name doesn't appear in the router

      WiFi.mode(WIFI_STA);
      WiFi.disconnect(); //Turn off all wifi connections.
      delay(100);
      WiFi.setHostname("M5StackCoreZaehler");
      WiFi.begin(ssid, password);
      M5.Lcd.print("Call to " + String(ssid));
      while (WiFi.status() != WL_CONNECTED) {
      M5.Lcd.print('.');
      delay(1000);
      }
      M5.Lcd.println(" ");
      M5.Lcd.println(WiFi.localIP());
      M5.Lcd.print("Signalstearke: ");
      M5.Lcd.println(WiFi.RSSI());
      server.begin();
      delay(4000);
      M5.Lcd.clear();

      1 Reply Last reply Reply Quote 0
      • felmueF
        felmue
        last edited by

        Hello @Stoni99

        looks like you need to call WiFi.config() before setting a new host name as well. Please see this article. (Note: not tested myself.)

        Thanks
        Felix

        GPIO translation table M5Stack / M5Core2
        Information about various M5Stack products.
        Code examples

        1 Reply Last reply Reply Quote 0
        • S
          Stoni99
          last edited by

          Unfortunately this doesn't work for me. I am doing something wrong?

          ......
          String hostname = "newName";
          ......

          void initWiFi() {
          WiFi.mode(WIFI_STA);
          //WiFi.disconnect(); //Turn off all wifi connections.
          //delay(100);
          WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE);
          WiFi.setHostname(hostname.c_str()); //define hostname (wifi.config muss davor stehen
          WiFi.begin(ssid, password);
          M5.Lcd.print("Call to " + String(ssid));
          while (WiFi.status() != WL_CONNECTED) {
          M5.Lcd.print('.');
          delay(1000);
          }
          M5.Lcd.println(" ");
          M5.Lcd.println(WiFi.localIP());
          M5.Lcd.print("Signalstearke: ");
          M5.Lcd.println(WiFi.RSSI());
          server.begin();
          delay(4000);
          M5.Lcd.clear();
          }

          1 Reply Last reply Reply Quote 0
          • felmueF
            felmue
            last edited by

            Hello @Stoni99

            have you tried to reboot your router? From above linked article:

            Important: you may need to restart your router for the changes to take effect.

            Thanks
            Felix

            GPIO translation table M5Stack / M5Core2
            Information about various M5Stack products.
            Code examples

            1 Reply Last reply Reply Quote 0
            • S
              Stoni99
              last edited by

              Unfortunately, a restart doesn't help either. maybe it's because of my older router.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post