Search code examples
arduinoipwifiesp32

How to change IP of ESP32 acting as an access point


So my goal here is to set the IP of my ESP32. I'm using this piece of code to do so, but I always end up with "192.168.4.1" - I want it to be: 192, 168, 1, 1

  WiFi.mode(WIFI_AP_STA);
  IPAddress Ip(192, 168, 1, 1);
  IPAddress NMask(255, 255, 255, 0);
  WiFi.softAPConfig(Ip, Ip, NMask);

  WiFi.softAP(ssid);
  IPAddress myIP = WiFi.softAPIP();
  Serial.println(myIP);

Solution

  • First stop the WiFi with WiFi.mode(WIFI_STA);