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:
setup:
connect to wifi
Loop:
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.
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 google.com. 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?