PlatformIO Community

pio\libdeps\esp32dev\DHT sensor library\DHT_U.h:36:29: fatal error: Adafruit_Sensor.h: No such file or directory

It doesn’t run libraries. Error in library paths. “.pio\libdeps\esp32dev\DHT sensor library\DHT_U.h:36:29: fatal error: Adafruit_Sensor.h: No such file or directory” I couldn’t find a solution. Any help?

What’s the platformio.ini?

Maybe with more context you could get help for instance by giving your platformio.ini and how/where have you installed your libraries ?

You can install the lib by using in the CLI command : pio lib

For instance for adafruit sensor lib : pio lib -g install 31

In this case, 31 is the ID number of the lib Adafruit unified sensor

The DHT library doesn’t work smoothly with PlatformIO. See other threads in this forum (e.g. Library dependency problem related to Core 5.0?).

The solution is simple. Add the following include statements to main.cpp:

#include <Adafruit_Sensor.h>
#include <DHT.h>
1 Like

I am getting an error even though I added it.

Again, please show the full platformio.ini and code that you’re using.

Ekran Alıntısı

The linking error is unrelated to the sensor code. It says there is no implementation of the loop() function.

same code and link Arduino IDE not giving error

Please show the entirety of the code as text. Use if the code is too long, or use markdown here.

I am uploading sample code of DHT11 library. DHT-sensor-library/DHTtester.ino at master · adafruit/DHT-sensor-library · GitHub

The code you show in the screenshot is very different from that. You have the DHT.cpp file saved as main.cpp there, not the DHTtester.ino sketch.

I’m getting the same error with all these libraries. I tried adding a different library and still got the same error.

In addition to the two mentioned headers, include Wire.h. Solved the same problem for my case.