Light switch is made with ESP8266 using micropython codes and connected to home router. It starts up fine but does not remain connected for long. The micro-controller needs to be reset frequently.
I have set the following ifconfig in boot.py to avoid random IP address.
station.ifconfig((‘192.168.0.113’,”,”,”))
Hi.
Yes, you can use that command to set a fixed IP address.
Do you have any other issue?
Regards,
Sara
ESP8266 nodeMCU when connected to the router and is accessed through a browser, browser does not remain connected for long though the IP address is available in web server. It cannot find the address after about 3-4 minutes. This time I have used Arduino IDE codes and added the following immediately after loop(). But it does not show the ‘#### Reconnected WiFi’ message on serial monitor. That means ESP does not get disconnected from the router. But the browser loses contact! Need suggestion.
//connect wifi if not connected
if (WiFi.status() != WL_CONNECTED) {
delay(1);
wifiManager.setSTAStaticIPConfig(IPAddress(192,168,0,103), IPAddress(192,168,0,1), IPAddress(255,255,255,0));
wifiManager.autoConnect(“MySwiFi”);
WiFi.hostname(deviceName);
WiFi.begin();
Serial.println(“#### Reconnected WiFi”);
server.begin();
return;
}
Hi.
when you say that the browser loses contact, what happens exactly?
Can you show me a printscreen? Or a be a little more specific?
Isn’t the browser able to find the web page?
Regards,
Sara
I am not sure what exactly happens. After 4 to 5 minutes, if I click a light switch button <created by html code inside Arduino IDE sketch> on my mobile screen, the browser search bar gets stuck for about 2 minutes and finally a message comes ‘This site can’t be reached’.
I can attach two screenshots which may give some clue for you. But how do I upload the pictures?
Hi.
If that’s the error, you don’t need to upload any pictures.
That usually means that the web server is not reachable or it is not able to serve the files (in this case, the HTML to build the web page).
Can you show me your complete code to experiment it myself?
To share code, you can use a link to pastebin or github, for example.
Regards,
Sara