Modify the IP address in WiFi_AP mode
Posted: Wed Jun 19, 2019 10:52 pm
Hi,
I'm trying to modify the IP address in the ESP32. I'm using it in the Access Point mode over WiFi.
In the serial monitor, it's showing the IP address as '1.0.0.0' instead of the one that I have defined.
If I remove the statement, 'WiFi.softAPConfig()', then I get the default '192.168.4.1' IP address in the serial monitor.
Where am I going wrong?
The following is my code:
I'm trying to modify the IP address in the ESP32. I'm using it in the Access Point mode over WiFi.
In the serial monitor, it's showing the IP address as '1.0.0.0' instead of the one that I have defined.
If I remove the statement, 'WiFi.softAPConfig()', then I get the default '192.168.4.1' IP address in the serial monitor.
Where am I going wrong?
The following is my code:
Code: Select all
#include <WiFi.h>
char ssid[] = "Network-1"; // your network SSID (name)
IPAddress IP = (10, 10, 1, 1);
IPAddress gateway = (10, 10, 1, 1);
IPAddress NMask = (255, 255, 255, 0);
WiFiServer server(80);
void setup ()
{
Serial.begin(115200);
Serial.println();
Serial.print("System Start");
WiFi.mode(WIFI_AP);
WiFi.softAP(ssid);
delay(1000);
WiFi.softAPConfig(IP, IP, NMask);
delay(1000);
IPAddress myIP = WiFi.softAPIP();
Serial.println();
Serial.print("AP IP address: ");
Serial.println(myIP);
server.begin();
}
void loop ()
{ }