There are times you are unable to connect to your WiFi router. This can be especially problematic when you have increasing number of WiFi dependent IoT devices. Many times, the remedy is to simply reboot the router i.e. unplug the power cord, wait for a few seconds and plug it back again.
If you do not want to go through that trouble on the ongoing basis, this apparatus will keep an eye on the wifi connectivity. If the connectivity goes down, it will turn on the buzzer to give warning to the user, then it will turn the router off for a predefined time using a relay. Will turn the router on again. After the router turns on, it will wait for a while to perform check on the WiFi.
This has been designed using Finite State Machine design pattern.
It uses MKR 1000 board that has built in WiFi. (You can also use Arduino with WiFi shield or equivalent.) It checks the WiFi connectivity by attempting to connect to google.com. If the connection is successful, it puts the device in the Connected State. In the Connected state, it simply waits for a period of time and switches to Checking state to perform periodic check.
If the connection is not successful, it puts the device in Disconnected state. This state will turn the buzzer on through port 3. Will wait for a few seconds and then enter RouterOff state.
When RouterOff state is entered, router is turned off by the relay connected on Port 0. After a while, it will turn the router on and change the state to RouterOn.
When RouterOn state is entered, router is turned on by relay. It waits for a while giving time to router to boot and start the WiFi. Then the state is changed to Checking which will perform the check.
Here are the steps to build it.
Step 1: Connect the Speaker
Connect pin 3 of Arduino to the red wire of the speaker
Connect ground of Arduino to the black wire of the speaker
Step 2: Connect the Relay
Take a power cord and cut one of its wires to connect to relay. Connect one end to the common terminal of the relay and other to the NC (Normally Closed) terminal of the relay. Be careful that the strands do not touch any other parts. Connect relay to Arduino as per schematics. Ensure that Relay is on non-conductive surface and preferably in non-conductive enclosure. This is important because the bottom part of the RELAY exposes HIGH VOLTAGE FROM the main electrical line. DO NOT Connect cord to main till the project is ready.
Connect Pin In1 of Relay to Digital Pin 0 of Arduino.
Step 3: Upload Sketch to Arduino
The code is provided in https://github.com/sameerkapps/KeepTheWiFiOn
Update the name of your network (SSID) and the password to connect to it.
Upload it to Arduino.
In the Setup, it configures Arduino pins and starts connection with WiFi. It then changes state to Checking state.
In the loop, based on the current state, it will call method to process the state.
If you like this project, please click the Respect button, share with your network and follow me.
Code on Github
Did you replicate this project? Share it!I made one
Love this project? Think it could be improved? Tell us what you think!