Project tutorial
Keep the WiFi On

Keep the WiFi On © GPL3+

If the WiFi connectivity goes down, this will reboot the router.

  • 38 respects

Components and supplies

Abx00004 iso both
Arduino MKR1000
Piezzo Buzzer
Songle Relay

About this project

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 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

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
Make sure to update your SSID and password in the code.


Schematics uses Arduino Micro Rev 3. As there is no schematics available for MKR 1000. Please replace that with MKR 1000.


Similar projects you might like

Mkr1000 Wifi Outlet

by thomas verley

  • 1 comment
  • 6 respects

WIFI Home Automation

Project showcase by user3736644255

  • 11 respects

WiFi IR Blaster

Project tutorial by BuddyC

  • 117 respects

Connect to Blynk using ESP8266 as Arduino Uno wifi shield

Project tutorial by Nolan Mathews

  • 70 respects

MKR1000 Connecting to the WiFi (3 steps)

by Anton Nazarenko

  • 27 respects
Add projectSign up / Login