🤖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)

    Scheduled Pinned Locked Moved Arduino
    5 Posts 2 Posters 6.9k Views
    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 Offline
      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 Online
        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 Offline
          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 Online
            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 Offline
              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

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              • First post
                Last post