I'm having an issue with compiling code for my Arduino Nano; I installed the adrafruit dht11 sensor library, it is in my folder, but I am unable to compile my code when I include it. The error message I'm getting is:
Arduino: 1.8.13 (Windows 10), Board: "Arduino Nano, ATmega328P"
In file included from C:\Users\jason\OneDrive\Documents\Arduino\sketch_may24a\sketch_may24a.ino:2:0:
C:\Users\jason\OneDrive\Documents\Arduino\libraries\DHT_sensor_library/DHT_U.h:36:10: fatal error: Adafruit_Sensor.h: No such file or directory
#include <Adafruit_Sensor.h>
^~~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Arduino Nano.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
(I didn't add the lines it just did that when I pasted.)
My code isn't the problem because the compiling issue happens when I have no code.
The file I downloaded is in my library's folder.
Thank you for your time.
Hi @drearydingo2. Something that might be a little confusing at first is that libraries can have dependencies on the code for other libraries. So you need to install the libraries your sketch uses, and the libraries those libraries use, and so on...
One thing to note is that the Arduino IDE's Library Manager can usually handle all this automagically for you. When you are installing libraries via Library Manager, you may get a dialog asking you:
Would you like to install also all the missing dependencies?
If so, click the Install all button. This will install all the libraries the library author defined as dependencies of their library, and all the dependencies defined by those libraries, and so on... This has been configured in the "DHT sensor library" you're using: https://github.com/adafruit/DHT-sensor-library/blob/master/library.properties#L10