Watchdog include file no longer available

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?

Thanks!

...almost certainly a lot longer than that.

The wdt code is available and works fine for me using the older IDE 1.8.19.

I see no reason to use IDE version 2 for anything, yet.

Did you have a non-VR board selected?

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.

You got it. OOPS!

And I see no reason not to use the latest stable release offered as the first choice on the official site.

It is not a "stable release", as you can see from all the complaints on this forum. There are plenty of bugs yet to be worked out.

Including, possibly, the unfortunate error(s) you just encountered.

Good luck with your project!

The error message should indicate the processor you're compiling for.
That's why I asked to see all of it.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.