I love mining and I truly believe that blockchain and digital currencies will one day change the world. Cryptocurrency has played a significant role in my life and has made me a morning person, ha ha. Miners require 24 x 7 access to the Internet. Recently, I went on a short business trip and my router for some stupid reason stopped working. I lost complete access to my home network and my miners. When I returned from my trip, my only aim was to fix this issue by creating an "Internet Hardware Watchdog" that reboots the router whenever something silly happens to it.
Note: If you do any work with "mains power" such as 120v or 240v AC power wiring, you should always use proper equipment and safety gears and determine whether you have adequate skill and experience or consult a Licensed Electrician. This project is not intended for use by children.
I love mining and I truly believe that blockchain and digital currencies will one day change the
world. Cryptocurrency has played a significant role in my life and had made me a morning person.
Miners require 24x7 access to the internet. Recently, I went on a short business trip
and my router for some stupid reason stopped working. I lost complete access to my home
network and my miners. When I returned from my trip, my only aim was to fix this issue
by creating a internet hardware watchdog that reboots the router whenever something
silly like this happens. This video is sponsored by PCBWay. PCBWay specializes
in manufacturing of very high quality, low volume, colored PCBs at a very budgetary price.
In addition to standard PCBs, you can order advanced PCBs, aluminum PCBs, rigid flex PCBs.
They also provide PCB assembly and other related services which can meet your need
at the greatest extent. Let me first explain the logic to you. In a nutshell,
in this setup, I'm going to ping google.com and as soon as the ping drops, I'll reboot the router.
To achieve this, the NodeMCU first connects to the Wi-Fi network and then pings google.com.
If it receives a successful ping, one out of the three blue LED patterns is displayed.
If the ping fails, five more retries are given before rebooting the router.
The reason I am not rebooting the router straight away is to avoid false positive
ping fail responses. However, once the fail count counter becomes five,
NodeMCU turns off the router by pulling the armature of the relay module. The armature
of the relay is held for 15 seconds before releasing it so that the router is properly
power cycled. Once the armature is released, the system waits for a minute before sending the next
ping request. This gives enough time to the router to successfully perform its post activities.
The above steps are then endlessly repeated in the loop section of the code.
For this project, we need NodeMCU, step down converter, relay module, two red LEDs,
three blue LEDs, 100 ohm resistor, power plug and a power socket.
Now let's put the components together exactly the way I have shown in the schematic diagram.
Be careful while handling AC main power socket and cables.
The step down converter powers the NodeMCU and the relay module.
LEDs are connected to the digital pin of the microcontroller.
The relay acts as a switch and switches on or off the router based on the ping responses.
Please make sure you check the pins of your relay module before hooking it up to the circuit.
So this is how my board looks like in 2D and 3D.
I basically have created a replica of the NodeMCU prototyping board
which you can buy from AliExpress for about 4 or 5 bucks.
Once I had my design ready, I just had to upload the Gerber file to the PCBWay's website
and then select the type, color and any other customization that I want
and then just send it for fabrication. For my project, I chose the black color.
PCBWay ships from China to most of the countries of the world within 3 to 7 business days.
Let's start by soldering the NodeMCU to the board.
Since I care a lot about my sensors and microcontrollers,
I am not going to solder them directly to the board.
Instead, I am soldering female pin headers to the board
which will house all the sensors and the microcontrollers in them.
I initially thought of soldering the LEDs directly on the board.
However, something clicked in my mind and I went ahead and soldered them
on a separate perf board and then soldered the perf board on the NodeMCU development board.
Well, this was totally unnecessary.
Once the LEDs were in place,
my next step was to solder the step-down converter and the relay module to the board.
If you want to know how I created this relay module,
please check out my tutorial number 19, DIY Relay Module.
The video and the blog post link are in the description below.
Before moving ahead, let's see how this setup looks like in the acrylic box.
Next, I made a hole in the transplant box and glued the power socket to it.
Well, I created a bit of mess while gluing the socket
and accidentally glued the box on my dining table.
Silly me.
I also drilled a hole at the back of the box
for the cable that will connect to the AC main power supply.
Pretty much, that's it.
Once again, I would like to warn you guys,
if you do any work with main power,
you should always use proper equipment and safety gears
and determine whether you have adequate skill and experience
or please consult a licensed electrician.
This project is not intended for use by children.
To conclude the setup, I added a small skull inside the acrylic box.
This skull has been sitting on my desk just collecting dust for over a year.
Now, let's have a look at the code.
You can download the code and all other resources
from the link provided in the description below.
To run the attached code,
you need to download and install ESP8266 ping library.
You can either download it from GitHub
or from the link provided in the description below.
Unzip and copy the archive to the Arduino's library folder
and change the board type to NodeMCU.
The code starts by including all the libraries and variables on top.
Then, in the setup section, I have defined all the pin modes
and have made a connection to the Wi-Fi router.
In the loop section, I'm performing a ping test
and based on the result, I am either blinking the blue LEDs
or power cycling the router.
So, this is how my internet watchdog looks like.
Do let me know if you guys like it.
Thanks again for watching this video.
I hope it helps you.
If you want to support me, you can subscribe to my channel
and watch my other videos.
Thanks.
See you again in my next video.
Bye now.