Main Content

Make an automatic router re-starter for $3 with an ESP8266 01 and single relay

The weakest link of our digital lives at home is the pipe into our house and the device it’s attached to. Our cable-modem allows our equipment to communicate with the outside world.

Like all computers, modems are prone to crashing; some of us need to restart at least once a week.

Recently my modem began disconnecting once a day, and because I can’t face the hassle of setting up a new one, I decided on a workaround.

If a sensor could detect when the modem disconnected, it could power-cycle by itself.

The project ended up being much simpler and cheaper than I expected.

- ESP8266 01 - costs about $1.50 from Aliexpress.
- Programming board for the ESP. Some of us already have a programmer, but if you buy both together, you can get them for about $2.50.
- A small relay board for the ESP. Search for ESP8266 5V 1CH Relay Module ESP-01. This also costs about a $1.

How it works
In layman’s terms, the process is simple. The ESP periodically pings Google through the modem. If it gets a reply, it does nothing; the relay stays closed and the modem stays on.

If the ESP does not get a reply, it will “understand” that the modem is down. When this happens, it turns off the relay, waits 30 seconds, then turns it back on, thus power-cycling the modem.

Infinite Loop
One flaw had me stumped for a while before I worked it out.

We all know that it takes the modem a few minutes to successfully “handshake” with the line. When I first set up my device, the ESP kept pinging Google during setup. As the modem hadn’t yet connected, the ESP got no reply - so did a power-cycle. I was in an infinite loop getting nowhere.

I needed the ESP to give the modem time to successfully handshake. Once this happened, the ESP would enter its regular polling of Google.”

Link to article