DHT Library Problem

Ok, now, after solving the LCD Issue, now my next problem:

I try to connect a dht22 sensor. There is a DHT-Library available, i can include it, but when i try to instantiate an object, it says “dht.h not found”. I am confused with the libraries and the different location where they should be or not:

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <DHT.h>

dht DHT;

3:17: warning: DHT.h: No such file or directory
5: error: ‘dht’ does not name a type

I already searched for solutions, but they seem not solved the issues.

regards and thank you!

Hi coliban

Download the DHT library. If it is in a zip file, unzip to somewhere (e.g. desktop).

You should then have a folder with at least two files in it - DHT.h and DHT.cpp. Rename the folder to DHT, if it is not already called that.

In Arduino IDE, select Sketch - Import Library - Add Library. Select the downloaded DHT folder and click OK. You should get a success message.



Hello Hackscribble,

thank you!

I´ve done this, like you wrote it, but it says, still the same:

air.ino:3:17: warning: DHT.h: No such file or directory
air:7: error: 'dht' does not name a type


Hello Hackscribble,

i solved the first problem, the name of the include file ist not “dht.h”, it is “dht22.h” and the class is named “DHT22”, which leads to the code:

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <DHT22.h>

int sensorPin = 1;
DHT22 mySensor(sensorPin);

which will compile and upload. I am now searching, how to connect the dht22 properly, until now the uno says, that humadity and temperature is “-99,5” but i have an other impression of the temperature here. I try, where to connect the dht22 pin.

Thank you and regards

There is information on connecting the DHT22 here ...


Your code specifies pin 1 ...

int sensorPin = 1;

That may clash with the serial monitor. Try changing it to (for example) pin 2 and connect the signal lead of the DHT22 to pin 2.

Hey, Hackscribble,

you are right!

It was the old version, now i have it (to pin 2)corrected and it seems, that the DHT22 is quite working, althought it seems that is not too accurate, i tested temperature with a calibrated device.


i have installed the dht library successfully and when i compile the DHTtester example that comes with the library i get the following error:
Arduino: 1.6.8 Hourly Build 2016/02/22 10:33 (Windows 7), Board: “NodeMCU 1.0 (ESP-12E Module), 80 MHz, Serial, 115200, 4M (3M SPIFFS)”

WARNING: Spurious .github folder in ‘DHT sensor library’ library
In file included from C:\Users\hassan\Documents\Arduino\libraries\DHT\DHT_U.cpp:22:0:

C:\Users\hassan\Documents\Arduino\libraries\DHT\DHT_U.h:25:29: fatal error: Adafruit_Sensor.h: No such file or directory

#include <Adafruit_Sensor.h>


compilation terminated.

exit status 1
Error compiling.

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

any help plz