Trying to set up static IP on ESP32

dal

dal

Associate
Joined
10 Sep 2005
Posts
909
Location
Lincolnshire
So I've tried to set up static IP on a ESP32 using this code link, it seems to work, on the serial monitor it prints : WiFi connected & prints the IP address but I just can't connect to the IP. When I type the IP into my browser it says this site can't be reached 192.168.43.201 took too long to respond. The code in the link has html in so I think I should be able to connect but I can't. I then tried to ping the ip from my hub. I get the following :
PING 192.168.43.201 (192.168.43.201): 64 data bytes
--- 192.168.43.201 ping statistics ---
3 packets transmitted, 0 packets received, 100% packet loss

Obviously I have changed my ssid & password in the code (lines 4 & 5) and also changed the gateway & subnet ( lines 34, 35) so I'm really not sure what I'm doing wrong.
Any help greatly appreciated.
 
Is the IP address of the network your PC is connected to 192.168.43.0? If not it won't work.

Set the ESP32 ip address to 192.168.1.201 or whatever your network address is - otherwise the devices are not on the same subnet and won't answer each other.

Basically the first three numbers in the IP address must match on both devices.

These three lines need changing in the script:

IPAddress local_IP(192,168,43,201);
IPAddress gateway(192,168,43,1);
IPAddress subnet(255,255,0,0);


change the 43 to the actual number your network address is set to and that subnet is wrong for a 192.168.x.x Class C network (most home lans) - it should read IPAddress subnet(255,255,255,0);
 
Last edited:
Is the IP address of the network your PC is connected to 192.168.43.0? If not it won't work.

Set the ESP32 ip address to 192.168.1.201 or whatever your network address is - otherwise the devices are not on the same subnet and won't answer each other.

Basically the first three numbers in the IP address must match on both devices.

These three lines need changing in the script:

IPAddress local_IP(192,168,43,201);
IPAddress gateway(192,168,43,1);
IPAddress subnet(255,255,0,0);


change the 43 to the actual number your network address is set to and that subnet is wrong for a 192.168.x.x Class C network (most home lans) - it should read IPAddress subnet(255,255,255,0);
Ok thanks I'll check that later, this may be where I've gone wrong
 
Back
Top Bottom