Auto modem reset when internet down

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 so you can see the process, and possibly adapt bits of it for your own interpretation.

Paul

5 Likes