HEC Electronic

Daniel Pineau
B.Eng.

Arduino Watchdog

Arduino and ESPxxxx microcontroller modules are well suited for rapid prototyping. They are used by talented hobbyist but also by engineers and researchers who want to obtain prototypes quickly to validate concepts. They can also be integrated into final devices, finished products.
Used for control and or home automation, they must be very reliable. To this end, the designers of the Arduino and ESPxxxx have provided watchdogs to wake up the microcontroller if it ever falls into an infinite loop or completely stops.
Unfortunately these internal watchdogs do not always work well. In some particular case while waiting for a WIFI connection, or is difficult to debug in certain code.
So I decided to design an external one. 

Design

The concept is to make a reset, not by the reset pin of the microcontroller but a reset by stopping the power supply. This is the ultimate reset. Because, in fact:  a reset using the reset pin is not completely reliable. If the microprocessor is working, lines of code will send impulses to an output port to neutralize the reset impulses (de-power-feeding) sent by the external watchdog.

The diagram in the following figure shows you the watchdog circuit.

Let us assume the case where C1 is at 0 volts. C1 is charged by the base current of Q2. When the voltage at the emitter of Q2 reaches about 3 volts, the voltage at the output of U1 switches to 0. This switches the voltage from U2 to 1. At this time Q1 is biased and causes C1 to discharge. The voltage of C1 and that of the emitter of Q2 will drop to about 2.3 volts. The voltage at the output of U1 will then switch to 1.

We therefore have here an astable circuit whose time constants are determined by C1, R1 and R2. The charge time constant is determined by R2, the gain of Q2 and C1. The discharge is determined by C1 and R1. Charging is much slower than discharging. So that with the current values the output of U1 produces a negative pulse of about 32 millisec every 8.4 sec.

Fig.1 : Negative pluse at U1 pin 4.

Fig.2: Charge an discharge of condenser C1