Material used
The tiny STWD100 comes in a SOT23-5 housing. To be able to use it on a breadboard, I soldered it on a pcb like this:

It can be ordered by searching for a "sot23-5 to dip10 adapter board".
Test 1
Goal of the test
This test is intended to investigate the possibility of using a STWD100 with an Arduino Nano.

Conditions for the test
Programming the Arduino with the Arduino IDE never failed in my testing with the reset line of the STWD100 connected to the Nano. But, we need the pull-up resistor on the /EN pin of the watchdog, and the following lines in the code (as early as possible):
digitalWrite (_EN, HIGH); // These 2 lines in this order! Otherwise the pin'll go low first. pinMode (_EN, OUTPUT); //Watchdog /EN Enable pin D7 - high to disable
Description and Result of the test
Testing the principles with some LED flashing loops.
At boot time, the LED flashes a few times. Then it starts blinking with intervals of 1s, with 50% duty-cycle.
During the first 12 blinks, the watchdog is toggled every edge of the LED toggle.
After the 12th blink, the watchdog is NOT triggered any more, and a reset follows (after 1.6s). The reset can be recognised, since the fast flashing starts again.
This is implemented as follows:
- In the beginning of the setup function, the /EN is kept high, so that it does not matter how long the setup lasts.
- In the loop function, the /EN is made active, and from this moment on, the WDI line should be toggled every second.
- If the WDI triggering stops, the STWD100 resets the Arduino.
Programming the Arduino with the Arduino IDE is no problem, the watchdog does not seem to disturb the process.
This test is positive. So, it is possible to add an external watchdog to an Arduino Nano!
Test 2
Description and result of CO2NodeTest2
The MySensors CO2 sensor node I built a while ago, (see CO2-Node-T6703-5K) sometimes crashes: every few months, the display freezes and nothing is broadcasted any more to the MySensors gateway.
In this state, pressing the reset button on the Arduino Nano resolves the problem.
Hence, I thought adding a hardware watchdog circuit would fix these crashes.
So, I added the hardware: a STWD100 and a 4K7 resistor. And after adapting the software, everything runs fine.
For keeping the watchdog /EN pin high during startup, I used the MySensors preHwInit() function, but that may not even be necessary:
void preHwInit() { digitalWrite (_EN, HIGH); // These 2 lines in this order! Otherwise the pin'll go low first. pinMode (_EN, OUTPUT); //Watchdog /EN Enable pin D7 - high to disable pinMode (WDI, OUTPUT); //Watchdog WDI pin D8 }
This test is positive.
Programming
- Test1 uses the Arduino IDE.
- CO2NodeTest2 uses Platformio.
Code at: Test1.ino and CO2NodeTest2.ino.