Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. General Discussion
  3. set hostname using static IP

set hostname using static IP

Scheduled Pinned Locked Moved General Discussion
mysensorshostname static
3 Posts 3 Posters 42 Views 3 Watching
  • 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
    S Offline
    sandorhoffmann
    wrote last edited by
    #1

    Hi,
    I'm new here, and I did not find any search feature, and I could no find anything with google in this topic.

    Hi, I have a lot of ESP32 devices with static IP. Is it possible to set hostname for them?
    I have a TP-Link DECO system, I see the devices but the hostname like this: "Device_29D0", and the MAC does not match to the give one (in MY_MAC_ADDRESS).

    I found this, but as I see it is only for DHCP.
    // Set the hostname for the WiFi Client. This is the hostname
    // it will pass to the DHCP server if not static.
    #define MY_HOSTNAME "my_custom_hostname"

    What did I wrong? :)
    Is this any possibility?

    Thanks,
    SH

    OldSurferDudeO 1 Reply Last reply
    0
    • S sandorhoffmann

      Hi,
      I'm new here, and I did not find any search feature, and I could no find anything with google in this topic.

      Hi, I have a lot of ESP32 devices with static IP. Is it possible to set hostname for them?
      I have a TP-Link DECO system, I see the devices but the hostname like this: "Device_29D0", and the MAC does not match to the give one (in MY_MAC_ADDRESS).

      I found this, but as I see it is only for DHCP.
      // Set the hostname for the WiFi Client. This is the hostname
      // it will pass to the DHCP server if not static.
      #define MY_HOSTNAME "my_custom_hostname"

      What did I wrong? :)
      Is this any possibility?

      Thanks,
      SH

      OldSurferDudeO Offline
      OldSurferDudeO Offline
      OldSurferDude
      wrote last edited by
      #2

      @sandorhoffmann I hope there is someone that can answer your question.

      But, I really recommend using DHCP. In that way, you can control all of your IPaddresses in one place, your DHCP server (almost always, your router)

      The huge advantage of ESP devices over Arduino is the WiFi. You don't need a big library. The MAC address is hard coded at the factory. I'm not sure that you can change it, which you would want to do if a device failed and you need an EXACT replacement.

      The downside of ESP is also the WiFi. Most home routers can only handle 20-30 WiFi devices My Asus routers start dropping WiFi devices resulting in difficult reconnects. The network becomes unusable. Because I have many ESP devices, I employed a Ubiquity access point that can handle 300 WiFi devices. The routers can handle 254 (253?) IP assignments, though some only allow 64 DHCP assignments.

      There is a discussion on this forum someplace on the number of clients there can be in a MySensors network. In theory 254 (253?) is the max, though I am unaware if anyone has tested it. I use an RPi as my gateway and haven't had problems with too many devices. If one is considering a very large number I would recommend starting each sensors one at a time because the gateway way will assign the NodeID which gets written into location 0 of the EEPROM. Or burn a NodeID into the Arduino EEPROM before running the actual code.

      bottom line, you didn't do anything wrong, its the nature of the beast.

      1 Reply Last reply
      0
      • TheoLT Offline
        TheoLT Offline
        TheoL
        Contest Winner
        wrote last edited by
        #3

        I did a grep on the source code and found this snipper

        #if defined(MY_GATEWAY_ESP8266) || defined(MY_GATEWAY_ESP32)
        	// Turn off access point
        	WiFi.mode(WIFI_STA);
        #if defined(MY_GATEWAY_ESP8266)
        	WiFi.hostname(MY_HOSTNAME);
        #elif defined(MY_GATEWAY_ESP32)
        	WiFi.setHostname(MY_HOSTNAME);
        #endif
        #if defined(MY_IP_ADDRESS)
        	WiFi.config(_MQTT_clientIp, _gatewayIp, _subnetIp);
        #endif /* End of MY_IP_ADDRESS */
        	(void)WiFi.begin(MY_WIFI_SSID, MY_WIFI_PASSWORD, 0, MY_WIFI_BSSID);
        #endif
        

        MySensors uses the standard ESP libraries for this. So I expect it to work. But you need to provide at least a bit of source code. Right now it's hard to answer your question. Regarding to MySensors:

        • A HTTP hostname can only be set for Gateways that either use Wifi or Ethernet
        • For nodes you can provide a sketchname and that will be seen in your controller.

        Regarding to static non static IP addresses. I prefer to use DHCP and set that device in my router as a static IP. There I also give it another hostname. So that in case I have to replace my Gateway I can do it all in the router.

        Hope this helps. But please provide more info on what you're trying to achieve

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        23

        Online

        11.7k

        Users

        11.2k

        Topics

        113.1k

        Posts


        Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • MySensors
        • OpenHardware.io
        • Categories
        • Recent
        • Tags
        • Popular