So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By jeffas
#61706 You might be able to do this on your router/WiFi access point.
When the ESP connects to WiFi, it gets its IP address from the WiFi's DHCP server. A good router will allow you to associate a specific IP address with a given MAC address. With luck, it will allow you to specify a hostname as well.
User avatar
By GengusKahn
#61731 Hi there, to allow a fixed set of ports I use the changes to the mac presented to the router....

Code: Select all  //  Setting the Mac Address for presenting to the router

  uint8_t mac[] = {0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX};
  wifi_set_macaddr(STATION_IF, &mac[0]);
 
// Setting the host name from the CPUID....will mask changes to your mac....
// allowing the router to see the changed address

  sprintf(hostString, "ESP_%06X", ESP.getChipId());
  Serial.print("Hostname: ");
  Serial.println(hostString);
  WiFi.hostname(hostString);