Comments on: [SOLVED] Reconnect ESP8266 NodeMCU to Wi-Fi Network After Lost Connection https://randomnerdtutorials.com/solved-reconnect-esp8266-nodemcu-to-wifi/ Learn ESP8266, ESP32, Arduino, and Raspberry Pi Thu, 16 Nov 2023 15:15:39 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: AhmadReza https://randomnerdtutorials.com/solved-reconnect-esp8266-nodemcu-to-wifi/#comment-872383 Thu, 16 Nov 2023 15:15:39 +0000 https://randomnerdtutorials.com/?p=102447#comment-872383 Hi,
Which method is better?
Does the code work correctly when using the millis() function after 50 days?
Because the millis() function becomes 0 after about 50 days.

]]>
By: Drprez https://randomnerdtutorials.com/solved-reconnect-esp8266-nodemcu-to-wifi/#comment-829594 Tue, 11 Apr 2023 10:23:18 +0000 https://randomnerdtutorials.com/?p=102447#comment-829594 How would I code it in this situation. Using WiFi manager I connect to my network successfully. Then if it loses connection I want it to reconnect automatically. Since it once successfully connected we know the network is good so I want it to reconnect with those connection and continue to try until it connects.

However if on WiFi manager say I enter the wrong password I don’t want it stuck in a loop trying to connect using the wrong password thinking it lost a connection and keeps trying. But rather take me back to the WiFi manager page to enter the info again.

]]>
By: jmattioni https://randomnerdtutorials.com/solved-reconnect-esp8266-nodemcu-to-wifi/#comment-750859 Sat, 21 May 2022 14:44:28 +0000 https://randomnerdtutorials.com/?p=102447#comment-750859 Disconnect/connect seem to be working ok for me. The main issue I’m having right now is with the ESP8266 NodeMCU rebooting itself during periods of poor signal and/or interference. I suspect this is an issue with the TCP stack, but am not certain because it only happens to the field unit. I ordered a Wifi jammer to see if I can duplicate the poor signal conditions with my desktop dev unit.

]]>
By: Sergio https://randomnerdtutorials.com/solved-reconnect-esp8266-nodemcu-to-wifi/#comment-750418 Thu, 19 May 2022 22:48:02 +0000 https://randomnerdtutorials.com/?p=102447#comment-750418 From Perú, Fix with delay(200) in loop() to ESP8266 reconnect automatically

]]>
By: Sara Santos https://randomnerdtutorials.com/solved-reconnect-esp8266-nodemcu-to-wifi/#comment-728260 Wed, 23 Feb 2022 11:08:20 +0000 https://randomnerdtutorials.com/?p=102447#comment-728260 In reply to Akekec.

Hi.
Replace your – in the if statement with a –
You’re using an end dash and not a minus sign (-)
Regards,
Sara

]]>
By: Akekec https://randomnerdtutorials.com/solved-reconnect-esp8266-nodemcu-to-wifi/#comment-728247 Wed, 23 Feb 2022 09:28:35 +0000 https://randomnerdtutorials.com/?p=102447#comment-728247 In reply to Joe.

Hi Joe.
I applied
But where am I going wrong
Can you check please

#include <ESP8266WiFi.h>
unsigned long lastReconnectMillis = 0;

void loop()
{

if(WiFi.status() != WL_CONNECTED && millis() – lastReconnectMillis > 10000 /* 10 seconds idle time is enough*/)
{
lastReconnectMillis = millis();
WiFi.reconnect();
}

}

error expression;
exit status 1
extended character – is not valid in an identifier

]]>
By: jmattioni https://randomnerdtutorials.com/solved-reconnect-esp8266-nodemcu-to-wifi/#comment-718200 Tue, 11 Jan 2022 16:39:57 +0000 https://randomnerdtutorials.com/?p=102447#comment-718200 I tried the onDisconnect handler and it worked, but I found there were a lot of additional repeat disconnect events during the subsequent attempt to re-connect. For my application, doing a WiFi.status() check in the loop worked out best. It doesn’t have much overhead.

Also, it’s worth noting that there seems to be restrictions on what can be in the event handler code. This makes sense since handlers should be as short as possible. For example, don’t call delay() in an event handler – it won’t work.

]]>
By: Sara Santos https://randomnerdtutorials.com/solved-reconnect-esp8266-nodemcu-to-wifi/#comment-695720 Mon, 08 Nov 2021 11:30:38 +0000 https://randomnerdtutorials.com/?p=102447#comment-695720 In reply to Marcia Guimarães.

I answered in our forum: https://rntlab.com/question/nodemccu-wifi-network-no-longer-connects/

]]>
By: Marcia Guimarães https://randomnerdtutorials.com/solved-reconnect-esp8266-nodemcu-to-wifi/#comment-695258 Sun, 07 Nov 2021 16:57:49 +0000 https://randomnerdtutorials.com/?p=102447#comment-695258 Guys, good night !

I have 5 NodeMCU’s and they all no longer connect to my main Wifi network (VIVO-A7CD).
I made the flash of all erasing everything else they persist in not connecting to this network.
I erased the flash with several apps and also on the command line in Python.
(C:\Python27\Scripts>esptool.py –port COM6 –baud 115200 erase_flash)
But, they connect to another Wifi network (DeusTaVendo).
I’ve already changed the name of the main network on the VIVO router, but it still gives the same problem.

It’s not an antenna problem on the boards because the DeusTaVendo Wifi network is far from the boards.
Previously I used these cards to test with EEPROM, where I stored variables.
I uploaded a code to reset the EEPROM… but it didn’t fix the problem.

#include <EEPROM.h>
void setup() {
EEPROM.begin(512);
// write a 0 to all 512 bytes of the EEPROM
for (int i = 0; i < 512; i++) {
EEPROM.write(i, 0);
}
EEPROM.end();
}
void loop() {
}

And I did tests with SIPFFS too.
I uploaded the WifiManager for the boards and saw that it had the SSID / PASS of a network that I had here.
I uploaded uncommenting the line where ZERAL the wifi networks stored on the card.
OK. Reset !
But it didn’t fix the problem.
It continued not connecting to VIVO-A7CD and connecting to DeusTaVendo.
I really don’t know what else to do !
This wifi network has always worked. There was never any problem and now this. I don’t really know what else to do. It may be something I’m not seeing anymore, I see how this could be happening.
Anyone who knows a solution to this please respond.
Thanks !!

TAKE A LOOK AT THE PRINTS…

SimpleAuthentication (Examples > ESP8266WebServer)

https://drive.google.com/file/d/1DxwHsLLpe4ks_dsOIE9RU3IUJTr1FVHE/view?usp=sharing

https://drive.google.com/file/d/1eCwgt72x3-MAizvUflPpyqejBhBHoimU/view?usp=sharing

https://drive.google.com/file/d/1odSvcj2xM1Kz9y3sioulHREicxHXzqPi/view?usp=sharing

]]>
By: WILLIAM E WEBB https://randomnerdtutorials.com/solved-reconnect-esp8266-nodemcu-to-wifi/#comment-691846 Sun, 31 Oct 2021 14:17:26 +0000 https://randomnerdtutorials.com/?p=102447#comment-691846 In reply to Ambrogio Riboli.

I don’t know if I have a ‘good’ solution, but I do have a solution that keeps me connected for weeks or months even if my gateway router is rebooted. See my code here:

https://github.com/bill-orange/MicroPython

Also note the garbage collection:
f gc.mem_free() < 102000:
gc.collect()

I have found aggressive garbage collection to be helpful.

Bill

]]>