{"id":10117,"date":"2020-12-03T18:24:29","date_gmt":"2020-12-03T18:24:29","guid":{"rendered":"https:\/\/wolles-elektronikkiste.de\/watchdog-timer"},"modified":"2024-08-01T18:48:13","modified_gmt":"2024-08-01T18:48:13","slug":"watchdog-timer","status":"publish","type":"post","link":"https:\/\/wolles-elektronikkiste.de\/en\/watchdog-timer","title":{"rendered":"Watchdog Timer"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">About the post<\/h2>\n\n<p>After my articles about the <a href=\"https:\/\/wolles-elektronikkiste.de\/en\/timer-and-pwm-part-1-8-bit-timer0-2\" target=\"_blank\" rel=\"noopener noreferrer\">8-bit timers<\/a> and the <a href=\"https:\/\/wolles-elektronikkiste.de\/en\/timer-and-pwm-part-2-16-bit-timer1\" target=\"_blank\" rel=\"noopener noreferrer\">16-bit timer<\/a> of the Arduino UNO or the ATmega328P I would like to complete this topic with the watchdog timer. This article is about:<\/p>\r\n<ul>\r\n<li><a href=\"#Anker1\">What is a watchdog timer and why do I need it?<\/a><\/li>\r\n<li><a href=\"#Anker2\">The watchdog timer of the Arduino UNO (and other AVR MCUs)<\/a>\r\n<ul>\r\n<li><a href=\"#Anker3\">Setup<\/a><\/li>\r\n<li><a href=\"#Anker4\">Watchdog with system reset<\/a><\/li>\r\n<li><a href=\"#Anker5\">Watchdog with system reset and interrupt<\/a><\/li>\r\n<li><a href=\"#Anker6\">Turning off the watchdog timer<\/a><\/li>\r\n<li><a href=\"#Anker7\">&#8220;Always on&#8221; with WDTON Fuse bit<\/a><\/li>\r\n<li><a href=\"#Anker8\">Watchdog only with interrupt<\/a><\/li>\r\n<li><a href=\"#Anker9\">Waking up from sleep mode<\/a><\/li>\r\n<\/ul>\r\n<\/li>\r\n<li><a href=\"#Anker10\">The problem with the Arduino Pro Mini<\/a><\/li>\r\n<li><a href=\"#Anker11\">ESP8266&#8217;s watchdog timer<\/a><a id=\"Anker1\"><\/a><\/li>\r\n<\/ul>\r\n\n<h2 class=\"wp-block-heading\">What is a watchdog timer?<\/h2>\n\n<p>Under certain conditions, a microcontroller can hang up just like a PC due to unexpected conditions or programming errors. Most of the time, programming errors become immediately noticeable, but sometimes this happens later under special conditions that were not considered during programming. Also, errors in peripherals, such as communication lines or sensors, can cause the sketch to hang in a program loop.<\/p>\r\n<p>Simply put, the watchdog timer watches over the sketch by regularly expecting signs of life from it. If these are omitted, depending on the setting and microcontroller, a reset is performed after an adjustable time, an interrupt is triggered or both. More precisely, the watchdog timer is an automatic counter that triggers the mentioned actions when it reaches its limit, if it is not reset before.<\/p>\r\n<p>For example, an interrupt before the reset can be used to<\/p>\r\n<ul>\r\n<li>ensure safe conditions for the controlled system<\/li>\r\n<li>save parameters on an EEPROM for error analysis<\/li>\r\n<li>save the status of the program so that it continues its work at the right step after the reset (simple example: control of a washing machine) <a id=\"Anker2\"><\/a><\/li>\r\n<\/ul>\r\n\n<h2 class=\"wp-block-heading\">The watchdog timer of the Arduino (UNO)<\/h2>\n\n<p>The following guide applies to the whole ATmega 48 \/ 88 \/ 168 \/ 328 \/ 328P family. You can also find this in the <a href=\"https:\/\/ww1.microchip.com\/downloads\/en\/DeviceDoc\/ATmega48A-PA-88A-PA-168A-PA-328-P-DS-DS40002061A.pdf\" target=\"_blank\" rel=\"noopener noreferrer\">data sheet<\/a> from page 60. In principle, the information also applies to the other representatives of the AVR microcontrollers. However, not every time-out is available for every model. More information about the time-outs can be found <a href=\"https:\/\/www.nongnu.org\/avr-libc\/user-manual\/group__avr__watchdog.html\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.<\/p>\r\n\n<h3 class=\"wp-block-heading\">Settings<\/h3>\n\n<p>The watchdog timer of the Arduino UNO or the ATmega 328P is not controlled by the system clock like the other timers discussed earlier, but via a separate 128 kHz oscillator. This makes the sketches easier to transfer from one controller to another or if you change the system clock.<\/p>\r\n<p>You choose the settings of the watchdog timer in the Watchdog Timer Control Register WDTCSR:<\/p>\r\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/WDTCSR.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"97\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/WDTCSR-1024x97.png\" alt=\"The Watchdog Timer Control Register\" class=\"wp-image-5129\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/WDTCSR-1024x97.png 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/WDTCSR-300x29.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/WDTCSR-768x73.png 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/WDTCSR.png 1221w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">The Watchdog Timer Control Register<\/figcaption><\/figure>\n\n<ul>\r\n<li><strong>WDIF<\/strong>: Watchdog Interrupt Flag &#8211; the bit is set in case of a time-out of the watchdog timer, provided WDIE was previously set, too.<\/li>\r\n<li><strong>WDIE<\/strong>: Watchdog Interrupt Enable &#8211; if you set this bit, then a time-out of the watchdog timer triggers an interrupt.<\/li>\r\n<li><strong>WDPx<\/strong>: Watchdog Timer Prescaler &#8211; with these bits you set the period of the watchdog timer according to the following table.<\/li>\r\n<li><strong>WDCE<\/strong>: Watchdog Change Enable &#8211; if you want to change the watchdog timer settings, then you first have to set this bit. The procedure will be explained further down below.<\/li>\r\n<li><strong>WDE<\/strong>: Watchdog System Reset Enable &#8211; if you set this bit, a time-out of the watchdog timer triggers a reset of the microcontroller.<a id=\"Anker3\"><\/a><\/li>\r\n<\/ul>\r\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/WDT_Prescale_v2-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1001\" height=\"538\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/WDT_Prescale_v2-1.png\" alt=\"Table 1: Prescaler settings of the watchdog timer\" class=\"wp-image-6940\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/WDT_Prescale_v2-1.png 1001w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/WDT_Prescale_v2-1-300x161.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/WDT_Prescale_v2-1-768x413.png 768w\" sizes=\"auto, (max-width: 1001px) 100vw, 1001px\" \/><\/a><figcaption class=\"wp-element-caption\">Table 1: Prescaler settings of the watchdog timer<\/figcaption><\/figure>\n\n<h3 class=\"wp-block-heading\">Setting up the watchdog timer &#8211; step-by-step instruction<\/h3>\n\n<p>We&#8217;re starting easy. The following sketch hangs in a while-loop because I have &#8220;forgotten&#8221; the incrementing of my counter i.<a id=\"Anker4\"><\/a><\/p>\r\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-group=\"hanging_sketch.ino\" data-enlighter-title=\"hanging_sketch.ino\">void setup(){\r\n  Serial.begin(9600);\r\n  Serial.println(\"Program with endless loop...\");\r\n  Serial.println(\"Sketch starts...\");\r\n}\r\n\r\nvoid loop(){\r\n  endlessLoop();  \r\n  Serial.println(\"I will never print this...\");\r\n}\r\n\r\nvoid endlessLoop(){\r\n  int i = 0;\r\n  while(i &lt; 5){\r\n    \/\/do nothing\r\n  }\r\n}<\/pre>\r\n<p>&nbsp;<\/p>\r\n\r\n\n<h4 class=\"wp-block-heading\">Watchdog Timer with system reset<\/h4>\n\n<p>Now a watchdog is to set up to get out of the endless loop and restart the microcontroller:<\/p>\r\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-group=\"watchdog_with_system_reset.ino\" data-enlighter-title=\"watchdog_with_system_reset.ino\">void setup(){\r\n  Serial.begin(9600);\r\n  Serial.println(\"Watchdog Timer Test\");\r\n  Serial.println(\"Sketch starts...\");\r\n  watchdogSetup();\r\n}\r\n\r\nvoid loop(){\r\n  endlessLoop();  \r\n  Serial.println(\"I will never print this...\");\r\n  asm(\"WDR\"); \/\/ this will not be executed\r\n}\r\n\r\nvoid watchdogSetup(void){\r\n  cli(); \/\/ disable all interrupts\r\n  asm(\"WDR\"); \/\/ watchdog reset\r\n  WDTCSR |= (1&lt;&lt;WDCE) | (1&lt;&lt;WDE);\r\n  WDTCSR = (1&lt;&lt;WDE) | (1&lt;&lt;WDP3); \/\/ 4s \/ no interrupt, system reset\r\n  sei();\r\n}\r\n\r\nvoid endlessLoop(){\r\n  static int seconds = 0;\r\n  int i = 0;\r\n  while(i &lt; 5){\r\n    Serial.print(seconds);\r\n    Serial.println(\" Sekunden\");\r\n    delay(1000);\r\n    seconds++;\r\n  }\r\n}<\/pre>\r\n<p>&nbsp;<\/p>\r\n\n<p>The setup of the watchdog timer is according to the following scheme:<\/p>\r\n<ul>\r\n<li><code>cli()<\/code> switches off all interrupts. This is necessary because the setup of the watchdog timer could be disrupted<\/li>\r\n<li><code>asm(\"WDR\");<\/code> is an assembler function for the watchdog reset; you will learn soon how to use a less cryptic function.<\/li>\r\n<li><code>WDTCSR |= (1&lt;&lt;WDCE) | (1&lt;&lt;WDE);<\/code> initiates the change of the watchdog parameters. It is important to use &#8220;|=&#8221; and not &#8220;=&#8221;. After this initialization, the actual change must be made within the next 4 clock cycles.<\/li>\r\n<li><code>WDTCSR = (1&lt;&lt;WDE) | (1&lt;&lt;WDP3);<\/code> means: Reset is enabled and the watchdog timer is set to four seconds (see settings table).<\/li>\r\n<li><code>sei();<\/code> switches interrupts on again.<\/li>\r\n<\/ul>\r\n<p>The watchdog reset at the end of the main loop (line 11) would prevent the system reset. However, this instruction will never be executed.<\/p>\r\n\n<p>Here&#8217;s what the output looks like on the serial monitor:<\/p>\r\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/watchdog_reset_ausgabe.png\"><img loading=\"lazy\" decoding=\"async\" width=\"716\" height=\"349\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/watchdog_reset_ausgabe.png\" alt=\"Watchdog timer reset\" class=\"wp-image-5141\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/watchdog_reset_ausgabe.png 716w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/watchdog_reset_ausgabe-300x146.png 300w\" sizes=\"auto, (max-width: 716px) 100vw, 716px\" \/><\/a><figcaption class=\"wp-element-caption\">Watchdog timer reset<\/figcaption><\/figure>\n\n<p>The watchdog works &#8211; the Arduino resets every four seconds. In theory, even the &#8220;4 seconds&#8221; should not be reached. However, the watchdog timer is less accurate than the other timers. Accordingly, the data sheet only specifies the time-out values as &#8220;typical&#8221;. <a id=\"Anker5\"><\/a><\/p>\r\n\n<h4 class=\"wp-block-heading\">Watchdog timer with system reset and interrupt<\/h4>\n\n<p>The following sketch still contains the infinite loop that leads to the watchdog time-out. Here, the time-out not only leads to a reset, but before an interrupt is triggered. This in turn calls the ISR (Interrupt Service Routine). For this purpose, you must pass &#8220;WDT_vect&#8221; to the ISR.<\/p>\r\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-group=\"watchdog_with_system_reset_and_Interrupt.ino\" data-enlighter-title=\"watchdog_with_system_reset_and_Interrupt.ino\">void setup(){\r\n  Serial.begin(9600);\r\n  Serial.println(\"*******************\");\r\n  Serial.println(\"Watchdog Timer Test\");\r\n  Serial.println(\"Sketch starts...\");\r\n  watchdogSetup();\r\n}\r\n\r\nvoid loop(){\r\n  endlessLoop();  \r\n  Serial.println(\"I will never print this...\");\r\n  asm(\"WDR\"); \/\/ Watchdog Reset will not happen\r\n}\r\n\r\nvoid watchdogSetup(void){\r\n  cli(); \/\/ disable all interrupts\r\n  asm(\"WDR\");\r\n  WDTCSR |= (1&lt;&lt;WDCE) | (1&lt;&lt;WDE);\r\n  WDTCSR = (1&lt;&lt;WDIE) | (1&lt;&lt;WDE) | (1&lt;&lt;WDP3); \/\/ 4s \/ interrupt, system reset\r\n  sei();\r\n}\r\n\r\nvoid endlessLoop(){\r\n  static int seconds = 0;\r\n  int i = 0;\r\n  while(i &lt; 5){\r\n    Serial.print(seconds);\r\n    Serial.println(\" Sekunden\");\r\n    delay(1000);\r\n    seconds++;\r\n  }\r\n}\r\n\r\nISR(WDT_vect){\r\n  Serial.println(\"....but I will print this before I reset soon\");\r\n}<\/pre>\r\n<p>&nbsp;<\/p>\r\n\n<p>Here&#8217;s what the output looks like:<\/p>\r\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/watchdog_reset_mit_interrupt.png\"><img loading=\"lazy\" decoding=\"async\" width=\"716\" height=\"405\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/watchdog_reset_mit_interrupt.png\" alt=\"Watchdog timer reset with previous interrupt\" class=\"wp-image-5144\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/watchdog_reset_mit_interrupt.png 716w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/watchdog_reset_mit_interrupt-300x170.png 300w\" sizes=\"auto, (max-width: 716px) 100vw, 716px\" \/><\/a><figcaption class=\"wp-element-caption\">Watchdog timer reset with previous interrupt<\/figcaption><\/figure>\n\n<p>As you can see, the sketch continues for another four seconds before the reset is triggered. The interrupt grants a deferral of one watchdog period. When selecting the watchdog timer period, you must therefore make sure that the actions to be performed before the reset fit into one period.<\/p>\n\n<h4 class=\"wp-block-heading\">Simplified notation with wdt.h<\/h4>\n\n<p>The cryptic setup of the watchdog timer can be made a little more pleasant by including the library &#8220;avr\/wdt.h&#8221;:<\/p>\r\n<ul>\r\n<li>You don&#8217;t have to worry about turning off the interrupts by <code>cli();<\/code> anymore.<\/li>\r\n<li>Instead of <code>asm(\"WDR\");<\/code> you can use <code>wdt_reset();<\/code>.<\/li>\r\n<li>The initialization by setting WDCE and the subsequent prescale setting is replaced by <code>wdt_enable(WDTO_XYZ);<\/code>, whereby WDTO_XYZ is selected from table 1.<\/li>\r\n<li>Strangely enough, no function is offered for activating the watchdog interrupt. To do this, you still need to use the binary operation <code>WDTCSR = (1&lt;&lt;WDIE);<\/code>.<\/li>\r\n<li>The watchdog interrupt without system reset <span style=\"text-decoration: underline;\">cannot<\/span> be set up with the wdt.h functions.<\/li>\r\n<\/ul>\r\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-group=\"watchdog_with_wdth_commands.ino\" data-enlighter-title=\"watchdog_with_wdth_commands.ino\">#include &lt;avr\/wdt.h&gt;\r\nvoid setup(){\r\n  Serial.begin(9600);\r\n  Serial.println(\"*******************\");\r\n  Serial.println(\"Watchdog Timer Test\");\r\n  Serial.println(\"Sketch starts...\");\r\n  watchdogSetup();\r\n}\r\n\r\nvoid loop(){\r\n  endlessLoop();  \r\n  Serial.println(\"I will never print this...\");\r\n  wdt_reset(); \/\/ Watchdog Reset will not happen\r\n}\r\n\r\nvoid watchdogSetup(void){\r\n  wdt_reset();\r\n  wdt_enable(WDTO_4S); \/\/ 4s \/ System Reset\r\n  WDTCSR = (1&lt;&lt;WDIE); \/\/ interrupt\r\n}\r\n\r\nvoid endlessLoop(){\r\n  static int seconds = 0;\r\n  int i = 0;\r\n  while(i &lt; 5){\r\n    Serial.print(seconds);\r\n    Serial.println(\" Sekunden\");\r\n    delay(1000);\r\n    seconds++;\r\n  }\r\n}\r\n\r\nISR(WDT_vect){\r\n  Serial.println(\"....but I will print this before I reset\");\r\n}<\/pre>\r\n<p>&nbsp;<\/p>\r\n\n<h4 class=\"wp-block-heading\">An &#8220;OK&#8221; sketch<\/h4>\n\n<p>For the sake of completeness, here is a sketch with a loop that ends in time. To do this, I inserted <code>i++<\/code> in line 30 and <code>i&lt;4<\/code> as a cancellation condition for the while loop.<\/p>\r\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-group=\"watchdog_with_finite_while.ino\" data-enlighter-title=\"watchdog_with_finite_while.ino\">#include &lt;avr\/wdt.h&gt;\r\nvoid setup(){\r\n  Serial.begin(9600);\r\n  Serial.println(\"*******************\");\r\n  Serial.println(\"Watchdog Timer Test\");\r\n  Serial.println(\"Sketch starts...\");\r\n  watchdogSetup();\r\n}\r\n\r\nvoid loop(){\r\n  finiteLoop();  \r\n  Serial.println(\"Now I will print this...\");\r\n  wdt_reset();\r\n}\r\n\r\nvoid watchdogSetup(void){\r\n  wdt_reset();\r\n  wdt_enable(WDTO_4S);\r\n  \/\/wdt_enable(WDTO_2S);\r\n  WDTCSR = (1&lt;&lt;WDIE);\r\n}\r\n\r\nvoid finiteLoop(){\r\n  static int seconds = 0;\r\n  int i = 0;\r\n  while(i &lt; 4){\r\n    Serial.print(seconds);\r\n    Serial.println(\" Sekunden\");\r\n    delay(1000);\r\n    i++;\r\n    seconds++;\r\n  }\r\n}\r\n\r\nISR(WDT_vect){\r\n  Serial.println(\"....but not this - as long there's no failure\");\r\n}<\/pre>\r\n<p>&nbsp;<\/p>\r\n\n<p>Here&#8217;s what the output looks like:<\/p>\r\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/Ausgabe_OK_Sketch.png\"><img loading=\"lazy\" decoding=\"async\" width=\"716\" height=\"405\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/Ausgabe_OK_Sketch.png\" alt=\"If the watchdog doesn't bite....\" class=\"wp-image-5160\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/Ausgabe_OK_Sketch.png 716w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/Ausgabe_OK_Sketch-300x170.png 300w\" sizes=\"auto, (max-width: 716px) 100vw, 716px\" \/><\/a><figcaption class=\"wp-element-caption\">If the watchdog doesn&#8217;t bite&#8230;.<\/figcaption><\/figure>\n\n<p>Try to comment line 18 and uncomment line 19 and see how the output changes.<a id=\"Anker6\"><\/a><\/p>\r\n\n<h4 class=\"wp-block-heading\">Turning off the watchdog timer<\/h4>\n\n<p>If you have included avr\/wdt.h, then you can simply turn off the watchdog timer using <code>wdt_disable();<\/code>. On a register level it looks like this:<\/p>\r\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-group=\"watchdog_off_function\" data-enlighter-title=\"watchdog_off_function\">void watchdogOff(){\r\n  cli();\r\n  asm(\"WDR\");\r\n  MCUSR &amp;= ~(1&lt;&lt;WDRF);\r\n  WDTCSR |= (1&lt;&lt;WDCE) | (1&lt;&lt;WDE);\r\n  WDTCSR = 0x00;\r\n  sei();\r\n}<\/pre>\r\n<p>&nbsp;<\/p>\r\n\n<p>Perhaps you have noticed the instruction <code>MCUSR &amp;= ~(1&lt;&lt;WDRF);<\/code>. MCUSR is the Microcontroller Status Register and WDRF is the Watchdog System Reset Flag bit. The latter overwrites the WDE bit in WDTCSR and therefore must be deleted first.<a id=\"Anker7\"><\/a><\/p>\r\n\n<h4 class=\"wp-block-heading\">Watchdog timer &#8220;always on&#8221; with the Fuse Bit WDTON<\/h4>\n\n<p>If you have a program like <a href=\"https:\/\/wolles-elektronikkiste.de\/en\/atmel-studio-7-an-introduction\" target=\"_blank\" rel=\"noopener noreferrer\">Atmel (Microchip) Studio<\/a> and a suitable programmer, you can also permanently activate the watchdog timer by setting the fuse bit WDTON. In this case, the reset mode is enabled without watchdog interrupt. So you can only modify the time-out.<a id=\"Anker7\"><\/a><\/p>\r\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/WDTON.png\"><img loading=\"lazy\" decoding=\"async\" width=\"746\" height=\"504\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/WDTON.png\" alt=\"Fuse bit programming in Atmel Studio\" class=\"wp-image-5165\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/WDTON.png 746w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/WDTON-300x203.png 300w\" sizes=\"auto, (max-width: 746px) 100vw, 746px\" \/><\/a><figcaption class=\"wp-element-caption\">Fuse bit programming in Atmel Studio<\/figcaption><\/figure>\n\n<h4 class=\"wp-block-heading\">Watchdog timer with interrupt and without reset<\/h4>\n\n<p>The variant with watchdog interrupt, but without system reset, cannot be realized in conjunction with <code>wdt_enable();<\/code>, as mentioned earlier. Therefore, you have to use the binary operations. Here&#8217;s an example:<\/p>\r\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-group=\"watchdog_with_interrupt_without_reset.ino\" data-enlighter-title=\"watchdog_with_interrupt_without_reset.ino\">#include &lt;avr\/wdt.h&gt;\r\n\r\nvoid setup(){\r\n  Serial.begin(9600);\r\n  watchdogSetup();\r\n}\r\n\r\nvoid loop(){\r\n  Serial.println(\"Here's the loop!\");\r\n  delay(1000);\r\n}\r\n\r\nvoid watchdogSetup(void){\r\n  cli();\r\n  wdt_reset();\r\n  WDTCSR |= (1&lt;&lt;WDCE) | (1&lt;&lt;WDE);\r\n  WDTCSR = (1&lt;&lt;WDIE) | (1&lt;&lt;WDP3);  \/\/ 4s \/ interrupt, no system reset\r\n  sei();\r\n}\r\n\r\nISR(WDT_vect){\r\n  Serial.println(\"Greetings from the ISR!\");\r\n}<\/pre>\r\n<p>&nbsp;<\/p>\r\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/Ausgabe_Interrupt_ohne_Reset.png\"><img loading=\"lazy\" decoding=\"async\" width=\"741\" height=\"405\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/Ausgabe_Interrupt_ohne_Reset.png\" alt=\"Watchdog timer interrupt without reset\" class=\"wp-image-5162\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/Ausgabe_Interrupt_ohne_Reset.png 741w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/Ausgabe_Interrupt_ohne_Reset-300x164.png 300w\" sizes=\"auto, (max-width: 741px) 100vw, 741px\" \/><\/a><figcaption class=\"wp-element-caption\">Watchdog timer interrupt without reset<\/figcaption><\/figure>\n\n<p>This setting of the watchdog timer is useful to let things be done periodically without having to consider time-dependent operations in the main loop. Perhaps a button is waiting to be pressed and a sensor needs to be read regularly. You could (mis-)use the watchdog interrupt to control the latter. Things like this can otherwise become complex. <a id=\"Anker9\"><\/a><\/p>\r\n\n<h4 class=\"wp-block-heading\">Wake up with the watchdog timer<\/h4>\n\n<p>The watchdog timer can also be used to wake the microcontroller from sleep mode. One possible application would be, for example, to control a sensor that is supposed to perform a measurement every few seconds. If there is nothing to do in between, you can send the microcontroller to sleep to save battery power. This sketch shows how this works in principle:<\/p>\r\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-group=\"wake_up_with_watchdog.ino\" data-enlighter-title=\"wake_up_with_watchdog.ino\">#include &lt;avr\/wdt.h&gt;\r\n#include &lt;avr\/sleep.h&gt;\r\nconst int ledPin = 12;\r\n\r\nvoid setup(){\r\n  pinMode(ledPin,OUTPUT);\r\n  watchdogSetup();\r\n}\r\n\r\nvoid loop(){\r\n  digitalWrite(ledPin,HIGH);\r\n  delay(500);\r\n  digitalWrite(ledPin,LOW);\r\n  set_sleep_mode(SLEEP_MODE_PWR_DOWN); \/\/ chose power down modus\r\n  sleep_mode(); \/\/ sleep now!\r\n  sleep_disable(); \/\/ disable sleep after wake up\r\n}\r\n\r\nvoid watchdogSetup(void){\r\n  cli();\r\n  wdt_reset();\r\n  WDTCSR |= (1&lt;&lt;WDCE) | (1&lt;&lt;WDE);\r\n  WDTCSR = (1&lt;&lt;WDIE) | (0&lt;&lt;WDE) | (1&lt;&lt;WDP3) | (1&lt;&lt;WDP0);  \/\/ 8s \/ interrupt, no system reset\r\n  sei();\r\n}\r\n\r\nISR(WDT_vect){\/\/put in additional code here\r\n}<\/pre>\r\n<p>&nbsp;<\/p>\r\n\r\n\n<p>Longer than 8 seconds of sleep is not possible with this method. If necessary, however, you could install a counter that ensures that the desired action is only triggered after the umpteenth wake-up. Otherwise, it goes back to sleep.<a id=\"Anker10\"><\/a><\/p>\r\n\n<h2 class=\"wp-block-heading\">Using watchdogs with the Arduino Pro Mini and Arduino Nano<\/h2>\n\n<h3 class=\"wp-block-heading\">The problem with the reset<\/h3>\n\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-large is-resized\">\r\n<figure><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2019\/03\/WNFF2775.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-478\" alt=\"\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2019\/03\/WNFF2775-1024x932.jpg\" width=\"256\" height=\"233\"><\/a><\/figure>\r\n<figcaption>Various Arduino Pro Mini boards<\/figcaption>\r\n<\/figure>\r\n<\/div>\r\n\n<p>The following sketch works well with the Arduino Uno without any problems. Every four seconds, the watchdog timer triggers a reset. If you try the same sketch on the Arduino Pro Mini or Arduino Nano, you will notice that the sketch only runs through once, and then it hangs.<\/p>\r\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-group=\"arduino_pro_mini_test.ino\" data-enlighter-title=\"arduino_pro_mini_test.ino\">#include &lt;avr\/wdt.h&gt;\r\nconst int ledPin = 12;\r\n\r\nvoid setup(){\r\n  pinMode(ledPin,OUTPUT);\r\n  watchdogSetup();\r\n}\r\n\r\nvoid loop(){\r\n  digitalWrite(ledPin,HIGH);\r\n  delay(1000);\r\n  digitalWrite(ledPin,LOW);\r\n  delay(500);\r\n  endlessLoop(); \r\n  wdt_reset(); \/\/ will not happen \r\n}\r\n\r\nvoid watchdogSetup(void){\r\n  cli(); \/\/ disable all interrupts\r\n  wdt_reset();\r\n  WDTCSR |= (1&lt;&lt;WDCE) | (1&lt;&lt;WDE);\r\n  WDTCSR = (1&lt;&lt;WDE) | (1&lt;&lt;WDP3); \/\/ 4s \/ no interrupt, system reset\r\n  sei();\r\n}\r\n\r\nvoid endlessLoop(){\r\n  int i = 0;\r\n  while(i &lt; 5){\r\n    delay(1000);\r\n  }\r\n}<\/pre>\r\n<p>&nbsp;<\/p>\r\n\n<p>A reset by the watchdog timer is not possible on the Arduino Pro Mini and it&#8217;s the same on the Arduino Nano. The problem is the bootloader. How to solve the problem by changing the bootloader is described <a href=\"https:\/\/andreasrohner.at\/posts\/Electronics\/How-to-make-the-Watchdog-Timer-work-on-an-Arduino-Pro-Mini-by-replacing-the-bootloader\/\" target=\"_blank\" rel=\"noopener noreferrer\">here.<\/a> But there are also two other simple alternatives, which I will describe below. Both are based on the watchdog being set with interrupt, but without reset. The reset is then done &#8220;manually&#8221; in the ISR.<\/p>\r\n\n<h3 class=\"wp-block-heading\">Workaround 1: Interrupt with hardware reset<\/h3>\n\n<p>A LOW signal on the reset pin of the Arduino Pro Mini initiates a hardware reset. You can use the following circuit and sketch:<\/p>\r\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/Pro_Mini_Hardware_Reset.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"415\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/Pro_Mini_Hardware_Reset-1024x415.png\" alt=\"Reset circuit for the Arduino Pro Mini\" class=\"wp-image-5172\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/Pro_Mini_Hardware_Reset-1024x415.png 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/Pro_Mini_Hardware_Reset-300x121.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/Pro_Mini_Hardware_Reset-768x311.png 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/Pro_Mini_Hardware_Reset.png 1077w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Reset circuit for the Arduino Pro Mini<\/figcaption><\/figure>\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-group=\"arduino_pro_mini_hardware_reset.ino\" data-enlighter-title=\"arduino_pro_mini_hardware_reset.ino\">#include &lt;avr\/wdt.h&gt;\r\nconst int ledPin = 12;\r\nconst int resetPin = 9;\r\n\r\nvoid setup(){\r\n  pinMode(ledPin,OUTPUT);\r\n  pinMode(resetPin,OUTPUT);\r\n  digitalWrite(resetPin,HIGH);\r\n  watchdogSetup();\r\n}\r\n\r\nvoid loop(){\r\n  digitalWrite(ledPin,HIGH);\r\n  delay(1000);\r\n  digitalWrite(ledPin,LOW);\r\n  delay(500);\r\n  endlessLoop(); \r\n  wdt_reset(); \/\/ will not happen \r\n}\r\n\r\nvoid watchdogSetup(void){\r\n  cli(); \/\/ disable all interrupts\r\n  wdt_reset();\r\n  WDTCSR |= (1&lt;&lt;WDCE) | (1&lt;&lt;WDE);\r\n  WDTCSR = (1&lt;&lt;WDIE) | (0&lt;&lt;WDE) | (1&lt;&lt;WDP3); \/\/ 4s \/ no interrupt, system reset\r\n  sei();\r\n}\r\n\r\nvoid hardwareReset(){\r\n  digitalWrite(resetPin,LOW);\r\n}\r\n\r\nvoid endlessLoop(){\r\n  int i = 0;\r\n  while(i &lt; 5){\r\n    delay(1000);\r\n  }\r\n}\r\n\r\nISR(WDT_vect){\r\n  hardwareReset();\r\n}<\/pre>\r\n<p>&nbsp;<\/p>\r\n\n<p><strong>If you swap lines 7 and line 8 in the sketch, you can do without the 1 kOhm resistor between pin 9 and RESET.<\/strong> Without swapping, the short time in which pin 9 is on OUTPUT and not yet HIGH is out is enough to give a reset signal.<\/p>\r\n\n<h3 class=\"wp-block-heading\">Workaround 2: Interrupt with software reset<\/h3>\n\n<p>For the second workaround, replace the hardwareReset() function with a software reset function: <code>void (*resetFunc)() = 0<\/code>. Then you call the function <code>resetFunc();<\/code> in the ISR. Or you just write directly to the ISR: <code>asm volatile (\"jmp 0\");<\/code>. No further wiring is necessary for this.<\/p>\r\n<p>The disadvantage of this method, however, is that there is no real reboot, but only a program restart. The microcontroller jumps to the address zero. All register contents, pin statuses, etc. are preserved as they are and can thus cause undesirable effects. So if necessary, you need to add a function to the setup that ensures a safe initial state. <a id=\"Anker11\"><\/a><\/p>\r\n\n<h2 class=\"wp-block-heading\">The watchdog at ESP8266<\/h2>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/ESP8266_ESP_12_ESP_01.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"431\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/ESP8266_ESP_12_ESP_01-1024x431.jpg\" alt=\"ESP8266 Versions\" class=\"wp-image-5187\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/ESP8266_ESP_12_ESP_01-1024x431.jpg 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/ESP8266_ESP_12_ESP_01-300x126.jpg 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/ESP8266_ESP_12_ESP_01-768x323.jpg 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/ESP8266_ESP_12_ESP_01-1536x646.jpg 1536w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/ESP8266_ESP_12_ESP_01-1320x555.jpg 1320w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/ESP8266_ESP_12_ESP_01.jpg 2000w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">ESP8266 Versions<\/figcaption><\/figure>\n\n<p>Compared to the AVR microcontrollers, the watchdog timer of the ESP8266 is basically designed differently. First of all, it has a hardware and a software watchdog timer. The software watchdog timer is automatically activated without any further intervention. Upload the following sketch on your ESP8266 and see what&#8217;s happening on the serial monitor (set 115200 Baud!)<\/p>\r\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">void setup() {\r\n  \/\/ESP.wdtDisable();\r\n}\r\n\r\nvoid loop() { \r\n  while(1){}             \r\n}<\/pre>\r\n<p>&nbsp;<\/p>\r\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/ESP8266_Software_Reset.png\"><img loading=\"lazy\" decoding=\"async\" width=\"741\" height=\"478\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/ESP8266_Software_Reset.png\" alt=\"Watchdog timer software reset - Output on serial monitor\" class=\"wp-image-5179\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/ESP8266_Software_Reset.png 741w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/ESP8266_Software_Reset-300x194.png 300w\" sizes=\"auto, (max-width: 741px) 100vw, 741px\" \/><\/a><figcaption class=\"wp-element-caption\">Software reset &#8211; Output on the serial monitor<\/figcaption><\/figure>\n\n<p>As you can see, the ESP8266 restarts approximately every three seconds. Figuratively speaking, the software watchdog &#8220;feeds&#8221; the hardware watchdog so that it doesn&#8217;t &#8220;bite.&#8221; To turn off the software watchdog, uncomment the function <code>ESP.wdDisable();<\/code> and see what happens:<\/p>\r\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/esp8266_hardware_reset.png\"><img loading=\"lazy\" decoding=\"async\" width=\"718\" height=\"349\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/esp8266_hardware_reset.png\" alt=\"Watchdog timer hardware reset - Output on serial monitor\" class=\"wp-image-5182\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/esp8266_hardware_reset.png 718w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/esp8266_hardware_reset-300x146.png 300w\" sizes=\"auto, (max-width: 718px) 100vw, 718px\" \/><\/a><figcaption class=\"wp-element-caption\">Hardware Reset &#8211; Output on the serial monitor<\/figcaption><\/figure>\n\n<p>Now there is a reset about every eight seconds and &#8220;wdt reset&#8221; appears on the serial monitor. That was the hardware watchdog. To prevent the watchdog from biting, you can feed it by inserting <code>ESP.wdtFeed();<\/code> into the while loop. However, you might as well insert <code>delay(x ms);<\/code> or any other function.<\/p>\r\n\n<h3 class=\"wp-block-heading\">Limited settings<\/h3>\n\n<p>There are virtually no ways to configure hardware and software watchdog timers on the ESP8266. Basically, you can only choose between the two watchdog variants. If you have turned off the software watchdog, you can activate it with <code>ESP.wdtEnable(x);<\/code> again. x is an integer value that must be passed to the function. This raises the hope that it could be used to control the time-out period. Unfortunately, that is not the case. It doesn&#8217;t matter if you choose e.g. <code>ESP.wdtEnable(0);<\/code> or <code>ESP.wdtEnable(4000);<\/code> or <code>ESP.wdtEnable(WDTO_4S);<\/code>, the effect is always the same.<\/p>\r\n\n<h3 class=\"wp-block-heading\">Create a more convenient watchdog timer yourself<\/h3>\n\n<p>If you need a watchdog timer that has similar functions to the AVR Watchdog Timer, you can create it yourself using the library Ticker.h with a few lines of code.<a href=\"https:\/\/gist.github.com\/dirkjanfaber\/1a80a73c491b6f8da9b7ec2047f4d7ea\" target=\"_blank\" rel=\"noopener\">Here<\/a> you find an example. <\/p>\r\n\n<h2 class=\"wp-block-heading\">Acknowledgement<\/h2>\n\n<p>The watchdog in the post picture I got from <a href=\"https:\/\/pixabay.com\/de\/users\/manfredrichter-4055600\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=4000952\" target=\"_blank\" rel=\"noopener noreferrer\">Manfred Richter<\/a> on <a href=\"https:\/\/pixabay.com\/de\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=4000952\" target=\"_blank\" rel=\"noopener noreferrer\">Pixabay<\/a>, the stopwatch comes from <a href=\"https:\/\/pixabay.com\/de\/users\/OpenClipart-Vectors-30363\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=160753\" target=\"_blank\" rel=\"noopener noreferrer\">OpenClipart-Vectors<\/a>, also <a href=\"https:\/\/pixabay.com\/de\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=160753\" target=\"_blank\" rel=\"noopener noreferrer\">Pixabay<\/a>.<\/p>\r\n\n<p>\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here you will learn: What is a watchdog timer? How to use it on Arduino (UNO) and AVR MCUs? What to consider using the watchdog timer on the ESP8266 and Arduino Pro Mini. <\/p>\n","protected":false},"author":1,"featured_media":8374,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[543],"tags":[1060,655,1055,997,1059,1054,1052,1050,1058,1051,1056,1053,1057],"class_list":["post-10117","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-boards-and-microcontrollers","tag-arduino-pro-mini-en","tag-esp8266-en","tag-hardware-reset-en","tag-isr-en","tag-sleep-en","tag-system-reset-en","tag-time-out-en","tag-watchdog-en","tag-watchdog-interrupt-en","tag-watchdog-timer-en","tag-wdt-h-en","tag-wdtcsr-en","tag-wdton-en"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Watchdog Timer &#8226; Wolles Elektronikkiste<\/title>\n<meta name=\"description\" content=\"Here you will learn: What is a watchdog timer? And: how to use it on Arduino (UNO) and AVR MCUs. What to consider using the watchdog timer on the ESP8266 and Arduino Pro Mini.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wolles-elektronikkiste.de\/en\/watchdog-timer\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Watchdog Timer &#8226; Wolles Elektronikkiste\" \/>\n<meta property=\"og:description\" content=\"Here you will learn: What is a watchdog timer? And: how to use it on Arduino (UNO) and AVR MCUs. What to consider using the watchdog timer on the ESP8266 and Arduino Pro Mini.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wolles-elektronikkiste.de\/en\/watchdog-timer\" \/>\n<meta property=\"og:site_name\" content=\"Wolles Elektronikkiste\" \/>\n<meta property=\"article:published_time\" content=\"2020-12-03T18:24:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-08-01T18:48:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/beitragsbild_klein.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1800\" \/>\n\t<meta property=\"og:image:height\" content=\"1800\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Wolfgang Ewald\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Wolfgang Ewald\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"14 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/watchdog-timer#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/watchdog-timer\"},\"author\":{\"name\":\"Wolfgang Ewald\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#\\\/schema\\\/person\\\/b774e4d64b4766889a2f7c6e5ec85b46\"},\"headline\":\"Watchdog Timer\",\"datePublished\":\"2020-12-03T18:24:29+00:00\",\"dateModified\":\"2024-08-01T18:48:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/watchdog-timer\"},\"wordCount\":2024,\"commentCount\":5,\"publisher\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#\\\/schema\\\/person\\\/b774e4d64b4766889a2f7c6e5ec85b46\"},\"image\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/watchdog-timer#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/beitragsbild_klein.jpg\",\"keywords\":[\"Arduino Pro Mini\",\"ESP8266\",\"hardware reset\",\"ISR\",\"sleep\",\"system reset\",\"time-out\",\"watchdog\",\"watchdog interrupt\",\"watchdog timer\",\"wdt.h\",\"WDTCSR\",\"WDTON\"],\"articleSection\":[\"Boards and Microcontrollers\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/watchdog-timer#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/watchdog-timer\",\"url\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/watchdog-timer\",\"name\":\"Watchdog Timer &#8226; Wolles Elektronikkiste\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/watchdog-timer#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/watchdog-timer#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/beitragsbild_klein.jpg\",\"datePublished\":\"2020-12-03T18:24:29+00:00\",\"dateModified\":\"2024-08-01T18:48:13+00:00\",\"description\":\"Here you will learn: What is a watchdog timer? And: how to use it on Arduino (UNO) and AVR MCUs. What to consider using the watchdog timer on the ESP8266 and Arduino Pro Mini.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/watchdog-timer#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/watchdog-timer\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/watchdog-timer#primaryimage\",\"url\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/beitragsbild_klein.jpg\",\"contentUrl\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/beitragsbild_klein.jpg\",\"width\":1800,\"height\":1800},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/watchdog-timer#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Startseite\",\"item\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Watchdog Timer\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#website\",\"url\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\",\"name\":\"Wolles Elektronikkiste\",\"description\":\"Die wunderbare Welt der Elektronik\",\"publisher\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#\\\/schema\\\/person\\\/b774e4d64b4766889a2f7c6e5ec85b46\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#\\\/schema\\\/person\\\/b774e4d64b4766889a2f7c6e5ec85b46\",\"name\":\"Wolfgang Ewald\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/cropped-Logo-1.png\",\"url\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/cropped-Logo-1.png\",\"contentUrl\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/cropped-Logo-1.png\",\"width\":512,\"height\":512,\"caption\":\"Wolfgang Ewald\"},\"logo\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/cropped-Logo-1.png\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Watchdog Timer &#8226; Wolles Elektronikkiste","description":"Here you will learn: What is a watchdog timer? And: how to use it on Arduino (UNO) and AVR MCUs. What to consider using the watchdog timer on the ESP8266 and Arduino Pro Mini.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/wolles-elektronikkiste.de\/en\/watchdog-timer","og_locale":"en_US","og_type":"article","og_title":"Watchdog Timer &#8226; Wolles Elektronikkiste","og_description":"Here you will learn: What is a watchdog timer? And: how to use it on Arduino (UNO) and AVR MCUs. What to consider using the watchdog timer on the ESP8266 and Arduino Pro Mini.","og_url":"https:\/\/wolles-elektronikkiste.de\/en\/watchdog-timer","og_site_name":"Wolles Elektronikkiste","article_published_time":"2020-12-03T18:24:29+00:00","article_modified_time":"2024-08-01T18:48:13+00:00","og_image":[{"width":1800,"height":1800,"url":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/beitragsbild_klein.jpg","type":"image\/jpeg"}],"author":"Wolfgang Ewald","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Wolfgang Ewald","Est. reading time":"14 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/wolles-elektronikkiste.de\/en\/watchdog-timer#article","isPartOf":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/watchdog-timer"},"author":{"name":"Wolfgang Ewald","@id":"https:\/\/wolles-elektronikkiste.de\/en#\/schema\/person\/b774e4d64b4766889a2f7c6e5ec85b46"},"headline":"Watchdog Timer","datePublished":"2020-12-03T18:24:29+00:00","dateModified":"2024-08-01T18:48:13+00:00","mainEntityOfPage":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/watchdog-timer"},"wordCount":2024,"commentCount":5,"publisher":{"@id":"https:\/\/wolles-elektronikkiste.de\/en#\/schema\/person\/b774e4d64b4766889a2f7c6e5ec85b46"},"image":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/watchdog-timer#primaryimage"},"thumbnailUrl":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/beitragsbild_klein.jpg","keywords":["Arduino Pro Mini","ESP8266","hardware reset","ISR","sleep","system reset","time-out","watchdog","watchdog interrupt","watchdog timer","wdt.h","WDTCSR","WDTON"],"articleSection":["Boards and Microcontrollers"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/wolles-elektronikkiste.de\/en\/watchdog-timer#respond"]}]},{"@type":"WebPage","@id":"https:\/\/wolles-elektronikkiste.de\/en\/watchdog-timer","url":"https:\/\/wolles-elektronikkiste.de\/en\/watchdog-timer","name":"Watchdog Timer &#8226; Wolles Elektronikkiste","isPartOf":{"@id":"https:\/\/wolles-elektronikkiste.de\/en#website"},"primaryImageOfPage":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/watchdog-timer#primaryimage"},"image":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/watchdog-timer#primaryimage"},"thumbnailUrl":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/beitragsbild_klein.jpg","datePublished":"2020-12-03T18:24:29+00:00","dateModified":"2024-08-01T18:48:13+00:00","description":"Here you will learn: What is a watchdog timer? And: how to use it on Arduino (UNO) and AVR MCUs. What to consider using the watchdog timer on the ESP8266 and Arduino Pro Mini.","breadcrumb":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/watchdog-timer#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wolles-elektronikkiste.de\/en\/watchdog-timer"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wolles-elektronikkiste.de\/en\/watchdog-timer#primaryimage","url":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/beitragsbild_klein.jpg","contentUrl":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/01\/beitragsbild_klein.jpg","width":1800,"height":1800},{"@type":"BreadcrumbList","@id":"https:\/\/wolles-elektronikkiste.de\/en\/watchdog-timer#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Startseite","item":"https:\/\/wolles-elektronikkiste.de\/en"},{"@type":"ListItem","position":2,"name":"Watchdog Timer"}]},{"@type":"WebSite","@id":"https:\/\/wolles-elektronikkiste.de\/en#website","url":"https:\/\/wolles-elektronikkiste.de\/en","name":"Wolles Elektronikkiste","description":"Die wunderbare Welt der Elektronik","publisher":{"@id":"https:\/\/wolles-elektronikkiste.de\/en#\/schema\/person\/b774e4d64b4766889a2f7c6e5ec85b46"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wolles-elektronikkiste.de\/en?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/wolles-elektronikkiste.de\/en#\/schema\/person\/b774e4d64b4766889a2f7c6e5ec85b46","name":"Wolfgang Ewald","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2019\/03\/cropped-Logo-1.png","url":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2019\/03\/cropped-Logo-1.png","contentUrl":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2019\/03\/cropped-Logo-1.png","width":512,"height":512,"caption":"Wolfgang Ewald"},"logo":{"@id":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2019\/03\/cropped-Logo-1.png"}}]}},"_links":{"self":[{"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/posts\/10117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/comments?post=10117"}],"version-history":[{"count":0,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/posts\/10117\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/media\/8374"}],"wp:attachment":[{"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/media?parent=10117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/categories?post=10117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/tags?post=10117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}