Reputation: 701
Hi i have tried to set a fixed ip for esp8266 Lolin. But always when i power off the board and power on, the IP changes. What i'm doing wrong?
My code :
WiFi.persistent(false);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
IPAddress ip(192,168,1,200);
IPAddress gateway(192,168,0,1);
IPAddress subnet(255,255,255,0);
WiFi.config(ip, gateway, subnet);
while (WiFi.status() != WL_CONNECTED) {
delay(250);
Serial.print(".");
}
Upvotes: 0
Views: 807
Reputation: 121649
I believe the answer is here:
https://github.com/esp8266/Arduino/issues/2371
You must set "WiFi.mode(WIFI_STA);" after WiFi.config and before WiFi.begin
Upvotes: 1