Reset AC Relay when Wifi is down.

Partly because of COVID I am not working anywhere near a modem that is essential to be up. I have a number of smart plugs for much of the essential equipment but they are all attached to the most volatile equipment, the wifi router and the modem.

I'd like to build a box that has a ESP8266 that makes sure it is connected/able to connect to the wifi and if not turn the power off for some time then back on - essentially rebooting the modem and router.

I have a UNO R3, a couple ESP8266, a couple Relays that are capable of controlling the load.

I've been fiddling a bit which has brought up some issues that I just can't seem to get past; mostly to do with the ESP8266-01. I've found several contradicting web sites for "beginners" in the operation of this board by putting the Reset to Ground on the UNO. On one chip I was able to get AT commands sent and connected to wifi through the COM screen in the IDE. Since I sent some code to the ESP I have only been able to send more code once, every other time it has given me trouble connect to the port at all.

Some web sites have suggested that there is not enough power to drive the transmit of the ESP8266 from the 3.3V on the UNO, others have added 10k resisters to the diagram.

Can someone tell me how to get my ESP board working through the IDE again?
If I need to drive it with an external power source what SPECIFIC equipment do I need?
Instead of programming the ESP chip, can't I program the UNO board to communicate with it?

That sounds too easy, the ESP8266 can easily do what you want. You will need a transistor and diode to drive the relay.
You will need a power source for the relay and ESP8266 which could possibly be from a USB supply (Need some one who knows this better to answer that)

I would do something like:
connect to wifi


if (WiFi.status() != WL_CONNECTED) {
change relay state

delay = X

change relay state to restart router

restart wifi

Maybe add a restart wifi counter and if it doesn't restart within a set number of attempts flash an LED, trigger an alarm get fancy and send a message to your phone with bluetooth.

You should be able to do this with just the Uno as well but will need to add a WiFi unit to the circuit.

This looks like some good instructions on how to use the esp8266-01

They tend to need a decent power supply (as wifi puts a lot of spikes of power draw on it) so I doubt the 3.3v from the Uno likley to work very reliably if at all.
Unless you specifically need to make it small I would recommend you get an esp8266 nodemcu type board as these have usb built in, more gpio pins to use and can be powered from 5volts so will make it much easier to use.
The cheap relay boards you can find on eBay are also very good for this type of thing as they have the transistor etc. all built in so very easy to wire to the esp8266 (just a single wire).

I would think the easiest option would be to periodically ping sites on the internet to check if all is still working ok.

As soon as you said "AT commands", I knew you were looking for the hard way to do this.
I have never seen Arduino plus ESP for WiFi work well. If you need WiFi, just start with a board that has WiFi.

My Verizon router has a bad habit of resetting itself a couple of times a day, so I built a board based on a Wemos D1 Mini that just pings my broker, my NAS, my Plex server, and one of a random selection of external IP's, such as Each time the ping is good, I light a green LED. If it fails, it's red. One glance of a green board gives confidence that all is good.

So, I would approach your problem similarly. Ping an external site every few seconds (I select one at random to keep from pinging so often that it might look like a DDOS attack). If the ping fails, cycle the modem power. Put enough time between the pings to make sure you don't ping again while the modem is starting.

The Wemos can control a relay to interrupt the modem power. The modem likely is powered by a wall-wart and 2.1mm barrel connectors. I would put the relay contacts on the low-voltage wire from the wall-wart using a set of M/F barrel connectors. The low-voltage side is safe to work with and the barrel connectors make changing the modem simple.

Thank you all; I appreciate the feedback. I was planning to just watch the wifi connection but after reading your comments I realize that the router could be working fine even with the modem down so I will probably include pinging externally as well.

SteveMann - the AT commands were part of a beginner web site project to ensure that you could connect before you started writing code. I will look for a board with wifi ... sounds much less complex.

The esp8266-01 has wifi built in and can be programmed just like an Arduino, in fact you will probably be surprised at how powerful they are. It would probably be an idea device for this project but the added complexity of not having built in USB, very limited io pins and needing a 3.3volt power supply may be best avoided for a first esp based project?

But if you want to give it a try you can use an Arduino Uno as an in circuit programmer:

Info on gpio pins

Thanks, I think you’re right, the limited pins wouldn’t give me enough capabilities. I am going to get a board with a built in ESP8266.

Thanks, I think you're right, the limited pins wouldn't give me enough capabilities. I am going to get a board with a built in ESP8266.

My go to board is the Wemos D1 Mini, and if I need more I/O pins, the NodeMCU, and if I still need more I/O, I can add MCP23017 port expander.

There is also the ESP32 boards, but I have zero experience with them.

BTW - I have just received a couple I ordered from here which arrived well within 2 weeks and seem to work ok, can’t argue with the price :slight_smile:

BTW - I would go for the second one (£1.71) as the cheaper one doesn’t fit on a breadboard and I think can have issues with Windows?

All of my ESP devices use the CH340 UARTs. They all fit the breadboard. But, if it's too wide, then use two breadboards side-by-side.

The ESP-01 relay module is all you need to match to your ESP-01 module and a power supply of 5volts.

Need a programmer.

The beautiful thing is that most of the arduino code will work on the 01 and s wemos Di mini.

Wemos Di mini also has a relay module shield.

If you buy extra power leads that match your modem. You can connect to the relay module and never Cut your modem leads. Just plug and playr

Another option is to use anUNO and an eithernet shield.

Another option is to use anUNO and an eithernet shield.

For the price of an UNO and Ethernet shield, you can buy six Wemos D1 Minis.