So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By giano2002@gmail.com
#95279 I am a newbie and find it difficult to write a program for the NodeMCU to restart a router if it hangs.

The program should:
1) continuously check if the ESP8266 is connected to the home WiFi (SSID and PW).
2) when the WiFi is no more connected, wait about 2 minutes and
3) if it is still disconnected,
4) activate a relay (which will turn off the router).
5) After 20 seconds, turn off the relais (so, the router will restart).
6) Wait another 4-5 minutes and if the WiFi is reconnected, go to 1) , otherwise, if the WiFi is still disconnected,
7) repeat from point 4).

I think the program is not difficult, but for me it is. So, is there somebody that could help me? I would be very grateful to him.

In fact, sometimes the modem / router of my mountain home crashes (perhaps when it is remotely updated by the Internet provider or for other reasons) and needs to be restarted. But since I am often not at home, all the devices connected to it (cameras, thermostats, etc.) remain deactivated and it is not possible for me to intervene remotely. Such a program could solve the problem.

Hope to receive some help.
Giano2002