Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- It always is a hassle if the router assigns a different IP address through DHCP because you have to open the serial monitor to see what's going on. I was already about to install in my lamps a little display, but the I found the solution.
- So it is much easier if you can set a static IP:
- I wasn't able to put it so neatly into the code like you, so I just commented in and out; but here is the recipe:
- */
- AccessPoint:
- ESP8266WebServer server(80);
- IPAddress apIP(192, 168, 5, 1); // if you want to configure another IP address comment it out for WebServer
- [in setup()]
- WiFi.mode(WIFI_AP);
- WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
- WiFi.softAP(ssid, password);
- server.begin();
- Webserver:
- WiFi.mode(WIFI_STA);
- // WiFi.config(IPAddress (your_new_IP), IPAddress (StandardGateway IP), IPAddress (255, 255, 255, 0)); // works only when I explicitely enter values
- WiFi.config(IPAddress (192,168,1,160), IPAddress (192,168,1,1), IPAddress (255, 255, 255, 0)); // works only when I explicitely enter values
- WiFiStart();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement