Dead easy to make DIY hadware watchdog for your mining rig

(на русском)

Hi! Welcome to my regular DIY hardware post series. This time around, we're going to make a hardware watchdog timer for your mining rig (or any PC, actually).

The focus of this device is its simplicity, as well as its constituent parts' cheapness and effortless sourcing. This build can be replicated even by those new to electronics and/or programming.

We'll begin by gathering the parts:



All the part that you'll need. Provided you don't mind general ugliness.
  • Any Arduino. My choice was Uno as it's the most widespread one. The only two requirements  it has to meet are: at least one digital I/O pin, at least one USB-enabled serial port.

  • Reed relay. Picking this relatively obscure kind of relay was based on a specific rationale. This relay's coil consumes only about 9mA at 5V, so you can drive it directly from AVR's IO pin:

  • 0.100" (2.54 mm) male and female headers (both):

Non-essentials (aka I don't want my device to fry because I poured some coffee on it) 

Do you want your stuff to look decent? Then gather these parts.
  • Project enclosure. I'll be using a lunchbox (tada!) to accentuate the simplicity of gathering parts for the project. Can be found at the nearest grocery store.

  • Some kind of 2-pin panel mount connector. This build utilizes a simple barrel jack commonly used to supply DC power:

  • Tiny screws and standoffs to affix Arduino to your enclosure:


  1. Screw the Arduino to the bottom of the box. The standoffs will come in handy.

  2. Make the apertures both for your reset key connector and for Arduino's USB connector. Round hole can be made with the help of a conical drill bit:

  3. A square hole is a bit trickier. Personally, I heated up an awl and blazed the tip through the box to cut arbitrary shaped holes in it. Resulting edges have to be finished with a hobby knife and/or small file.

  4. Solder together a little circuit:

  5. One remaining piece is the cord that'll connect your watchdog timer to computer's motherboard.

  6. You're all set with the hardware! Just close the top of the box and plug it in!


You'll find all required software (that is, Arduino sketch and Java program source code) along with detailed instructions in this Github repository. Java was chosen to ensure it can be run on both Windows and Linux - the two most widespread mining rig platforms.

Java app being built with Maven - the same thing will be seen by any Linux user.

Testing it all together

Upload the sketch on Arduino, connect it to your computer and run the .jar file that you built. At this point, if everything works fine, you'll finally observe your hardware-software bundle of Arduino and Java working together:

Here's how it works: the PC-side program tries to connect to every single serial port in your system within a period of 30 seconds (including the ports that appear during this process). To each port it'll send the handshake string "hello" and monitor the input, expecting to receive uppercase "HELLO" back. When the handshake is finished, it'll send ping strings once each five seconds.

The watchdog program on Arduino scans the input for "ping" strings. If no such string has been received within 10 second period, the watchdog will forcibly restart your PC.

Therefore, this scenario where you manually run it will be "one-off", i.e. once the PC has been restarted, the watchdog will be stuck in the pre-handshake state. To make it work all the time, add the Java program to the startup list of your operating system of choice.

Now, the most important part is plugging your watchdog instead of the reset switch on your motherboard:

That's when it'll be able to actually restart your PC.

As a substitute for proper ending, have this video of my friend battle-testing my watchdog with one of his buggy GPUs that's been causing him way too many BSODs than you'll expect:


  1. I want / need this for an always up Ryzen linux system. I was going to try one of those cheap USB watchdogs on amazon however I believe this will be a better solution since with this solution I will have way more control over the timing and also I will be able to debug the process. One thing I would want to do is greatly increase the timeout value in your software. I am a c++ programmer so I don't think that would be difficult at all.

    1. great to know that my humble watchdog setup will aid you :-) I agree that as geeks, having a hackable tool is better even if you have to invest some time in it. And yes, I believe tweaking a delay in Java code should be a piece of cake for you.

  2. Hi! Thanks you for this good job, and for sharing that with us.
    I've got an issue with the arduino program.
    Indeed, when I'm starting the java program on the computer, the relay is switching during the handshake (RESET_PIN to HIGH), so the computer is rebooting..
    I tried to find why, I tried with several arduino boards (nano, uno, mega) but the problem is still there.
    What do you think about that?

    1. This probably has something to do with the way your USB system is powered. Try powering Arduino through VIN pins additionally to USB port and see if it solves the issue.

    2. I needed to increase the timeout otherwise if I rebooted the watchdog may trigger when the system booted back up. If I have the desire I may update the code in my fork to tell the watchdog to stop (or possibly dynamically increase the timeout even more) in the case of a manual reboot.

  3. I already tried this, with an external power supply, on Arduino uno, and I've got the same issue.
    I really do not know what is wrong. I also tried using another computer, but it did'nt change anything :(

  4. Very good. I was searching while having exactly this Solution in mind. Will try it with arduino nano, micro and attiny85 digispark as well, but no donut this gonna work, i guess


Post a Comment