NOTE: this was a silly error - I was compiling for the wrong board, so you can stop reading now. Thanks to @johnwasser for pointing this out. The IDE apparently auto selected a board I used yesterday. Lesson learned: once you start using multiple boards, keep checking the bottom edge of the window.
I have been using a watchdog timer for years, and suddenly the header file isn't found. I'm on a new Windows 11 computer with Arduino IDE 2.0.3. I installed it from the download, not the Windows store.
People posted similar questions years ago, but the answers are no longer relevant and the questions are closed.
The exact message I get is:
fatal error: avr/wdt.h: No such file or directory #include <avr/wdt.h>
^~~~~~~~~~~
compilation terminated.
exit status 1
Compilation error: avr/wdt.h: No such file or directory
Here is a minimal example:
#include <avr/wdt.h>
void setup() {
wdt_enable(WDTO_8S);
}
void loop() {
// Do some things which could lead to bad results if they take too long.
wdt_reset();
}
In the past this library was installed automatically and simply needed to be included as shown in my example. How can I make it work with the new IDE?
Other than the temp file name at the beginning, there is nothing else in the window.
Here you go:
C:\Users\list\AppData\Local\Temp.arduinoIDE-unsaved2023116-18804-1lfzlt2.odeyk\sketch_feb16a\sketch_feb16a.ino:1:10: fatal error: avr/wdt.h: No such file or directory
1 | #include <avr/wdt.h>
| ^~~~~~~~~~~
compilation terminated.
exit status 1
Compilation error: avr/wdt.h: No such file or directory
BUT I did make another error. I had compiled and run a simple sketch for an Arduino Mega and then opened a second sketch with a watchdog timer, where I got this error. I failed to notice that in the second window the IDE switched to a Raspberry Pi Pico processor, which I had used the day before. Obviously the include file wasn't there because it looked for RP2040 include files, rather than AVR files.
I still would love to know why the IDE switched boards on me when I opened the existing sketch.
I'll see if I can edit the original question to clarify this.