• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

ESP8266 node MCU connection to router

Q&A Forum › Category: Home Automation › ESP8266 node MCU connection to router
0 Vote Up Vote Down
Subir Datta asked 5 years ago

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’,”,”,”)) 

5 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

Hi.
Yes, you can use that command to set a fixed IP address.
Do you have any other issue?
Regards,
Sara

0 Vote Up Vote Down
Subir Datta answered 5 years ago

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;
} 

0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

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

0 Vote Up Vote Down
Subir Datta answered 5 years ago

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?

0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

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
 

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.