# Auto modem reset when internet down

**URL:** <https://discourse.nodered.org/t/auto-modem-reset-when-internet-down/8386>\
**Category:** Share Your Projects\
**Created:** [26 February 2019 02:29 UTC](https://discourse.nodered.org/t/auto-modem-reset-when-internet-down/8386 "2019-02-26T02:29:52Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [26 February 2019 21:46 UTC](https://discourse.nodered.org/t/auto-modem-reset-when-internet-down/8386/6 "2019-02-26T21:46:15Z")

</div>

I started by using a node-RED flow which controlled a MQTT remote relayboard, which worked very similar to your flow above, and removed power from the router causing a reboot, but eventually decided to build a stand-alone device, which would not be reliant upon node-RED running, or having communication between node-RED and the relayboard, for better resilience.

I purchased a Wemos D1 Mini (ESP8266 device), also a 3V opto-isolated relay. Total cost about £4 from AliExpress!

Then wrote a sketch which;

1. Connects to my wifi
2. Every 20 minutes, it pings 'google' (and if no reply - then 'cloudflare') and if it gets  
a response, the ESP will go to deep sleep mode for 20 mins, then repeat.
3. If no reply is received from either, the sketch enters a loop, rechecking google &  
cloudflare, for a further 4 times, 1 minute apart.
4. If no reply is received, the relay will remove power to the router for 5  
seconds causing a router reboot.
5. ESP will then go into deep sleep for 5 minutes to allow the router to  
stabilise, then resume checking for connectivity.

I've just [uploaded the sketch to Github](https://github.com/Paul-Reed/router-reboot) so you can see the process, and possibly adapt bits of it for your own interpretation.

Paul

---

_[View the full topic](https://discourse.nodered.org/t/auto-modem-reset-when-internet-down/8386)._
