Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fatal error: avr/io.h: No such file or directory arduino

I'm trying to test a library for an DHT22 "Temperature Sensor", but I got an error while including an internal arduino library from the DHT.cpp file

I got this error:

C:\Program Files (x86)\Arduino\libraries\DHT\DHT22.cpp:56:20:
fatal error: avr/io.h: No such file or directory  #include <avr/io.h>

In the DHT22.cpp, this is the the block of error

extern "C" {
 #include <avr/io.h>
 #include <avr/interrupt.h>
 #include <avr/pgmspace.h>
}

I got in the conclusion that the library is not finding the avr folder which is in C:\Program Files (x86)\Arduino\hardware\tools\avr\avr\include\avr I checked another built-in library servo.cpp and this is the include part

#include <avr/interrupt.h>
#include <Arduino.h>

but the last one works without errors, my question is why the DHT library is not importing the required files and the servo does ?

like image 936
William Bello Avatar asked Dec 09 '25 05:12

William Bello


1 Answers

It looks like you are using some old version of the library (from 2012).

The latest version, which does not contain the problematic "extern" block, can be found here: https://github.com/adafruit/DHT-sensor-library

(The default example works nicely with my Arduino Nano v3.0 and DHT22 sensor)

like image 65
Viliam Simko Avatar answered Dec 12 '25 12:12

Viliam Simko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!