Unable to change IP, please help!
Posted:
Fri May 19, 2017 10:08 pm
by DG4EK
Hello,
I just spent the night with trying to change the IP adress using SETTINGS, but it didnt work,
the ESP allways came up with 192.168.4.1 regardless what I put into the field called IP.
The result is that it cannot connect to my router because it uses the fixed subnet mask FF:FF:FF:00
which I cannot change (I tried to give the ESP the IP 192.168.0.81).
Can anybody help please? What can I do?
Thanks a lot, regards
Peter
Re: Unable to change IP, please help!
Posted:
Mon Jun 19, 2017 5:18 pm
by nedudgi
DG4EK wrote:Hello,
I just spent the night with trying to change the IP adress using SETTINGS, but it didnt work,
the ESP allways came up with 192.168.4.1 regardless what I put into the field called IP.
...
We don't see, what You did in SETTINGS. Try to start with DHCP, leave the IP address field empty.
Re: Unable to change IP, please help!
Posted:
Tue Jun 20, 2017 6:58 am
by Electroguard
Go to SETTINGS, Station Mode (Connect to router):
In Name: enter the SSID of your router
In Pass: enter the routers password
Assuming your wifi router is configered to issue DHCP addresses to connecting clients the ESP will be assigned an IP address by the router.
If not, you will need to manually assign IP parameters... but don't go there unless you have to.
So if you have previously entered any address or subnet mask info anywhere - and you are not 100% sure of what you are doing - then clear it all out.
Click the Save button at the bottom
Click the Reboot button at the bottom
Assuming your wifi router authenticates the details you have given, the ESP device should restart and automatically connect to the router.
The allocated DHCP address will be the one you need to enter in the browser address bar to access the devices EDIT page etc (as you do with the default AP of 192.168.4.1).
The easiest and surest way of knowing what address has been assigned to the device is to have a serial port monitor connected during device bootup, which will show the allocated IP address (or else show the failed connection).
Don't forget to disconnect wifi from the old 192.168.4.1 AP and connect to your wifi router which your device is now connected to.
Now you can access that device IP address from the browser as normal.
If the device fails to authenticate and connect to the router, rather than leaving you adrift in a boat without a paddle it should help you safely back to shore by giving you the default 192.168.4.1 AP - so the default AP address is acting more like a lifeguard when you get yourself in trouble than a big bully that's preventing you doing anything.
Re: Unable to change IP, please help!
Posted:
Tue Nov 02, 2021 8:24 pm
by Sajith-Karunatilake
Change as necessary, and try this code! Good Luck!
Code: Select all#include <ESP8266WiFi.h>
const char* ssid = "REPLACE_WITH_YOUR_SSID";
const char* password = "REPLACE_WITH_YOUR_PASSWORD";
IPAddress subnet(255, 255, 0, 0);
IPAddress gateway(192, 168, 1, 1);
IPAddress local_IP(192, 168, 1, 184);
void setup() {
Serial.begin(115200);
if (WiFi.config(local_IP, gateway, subnet)) {
Serial.println("Static IP Configured");
}
else {
Serial.println("Static IP Configuration Failed");
}
WiFi.begin(ssid, password);
Serial.print("Connecting...");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi Connected! IP address:");
Serial.println(WiFi.localIP());
}
void loop(){
// YOUR CODE HERE
}