Adafruit_Sensor.h: No such file or directory

Posted on

Why does this error occur?

Adafruit has built many sensor libraries. Some of them depend on one library to another, so the error Adafruit_Sensor.h: No such file or directory appears.

One of them is a temperature sensor both DHT11 and DHT22 which you can download via the Adafruit github page here.

I also get this error when I run the Arduino Uno DHT11 Sensor program so the error No such file or directory appears.

Adafruit_Sensor.h: No such file or directory

In full you may find the same thing as shown in the following article:

In file included from /Arduino/libraries/DHT-sensor-library-master/DHT_U.cpp:15:0:
/Arduino/libraries/DHT-sensor-library-master/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 Uno.

How to fix this error

A little confusing when getting this error. But after looking for a solution I found that this DHT llibrary requires one more library that has been created by Adafruit Industries.

To fix this, we have to download and install the Unified Library from Adafruit. Please follow these steps:

  • Open your Arduino IDE
  • Click Sketch menu
  • Click Include Library
  • Click Manage Libraries
  • Use the keyword “Unified” in the search field
  • Scroll down and you will find “Adafruit Unified Sensor”
  • Please click Install
  • Done
Adafruit_Sensor.h: No such file or directory
  • After the installation is complete, go back to coding
  • Do a re-upload and you will succeed

If this article can help you and you want to share this article, you can use the following share buttons. Hopefully this article is useful.

May be you like:
> Ultrasonic HC-SR04 Arduino Distance Sensor
> IR Remote Sensor 1838B Arduino Tutorial
> TSOP1738 Arduino Tutorial IR Sensor Control RGB LED
> TTP223 Capacitive Touch Sensor Switch
> Panasonic AMG8833 Arduino Buzzer Notification at Specific Temperature
> HC SR501 Arduino PIR Basic Tutorial
> Download Fritzing Part, Library, PinOut Arduino STM32