Learn how to use DHT11 temperature and humidity sensor with Arduino. In this post we’ll go over the sensor pins, the connections to an Arduino UNO, the sensor specs, how to program in Arduino, the required libraries, and testing of the DHT11.
DHT11 Operating voltage, range, and accuracy
Sensor Voltage: 3.0V – 5.5V
Sensor Operating Range:
Relative Humidity:
Temperature | Range (RH) |
0oC (32oF) | 30% – 90% |
25oC (77oF) | 20% – 90% |
50oC (122oF) | 20% – 80% |
Temperature:
0oC to 50oC (32oF to 122oF)
Sensor Accuracy (error):
Temperature: ±2oC (±3.6oF)
Relative Humidity: ±5%
For more details on the sensor specs, see the datasheet.
Downloading the libraries
Download the Simple DHT library (Zip file) – LINK. Once downloaded, we will go ahead and install in Arduino IDE.

Installing the Simple DHT library
Once the Zip library has been downloaded, you need to import it within the Arduino IDE. To do this, go to the top menu, then click Sketch, Include Library, Add .Zip Library… Then, find the Zip file in the folder in which you downloaded it, select the Zip file and click open to import into Arduino IDE.
Once you do this, we will be ready to go into programming in Arduino!
Arduino Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
//Arduino Code - DHT11 #include <SimpleDHT.h> int pinDHT11 = 2; SimpleDHT11 dht11(pinDHT11); void setup() { Serial.begin(9600); } void loop() { // read without samples. byte temperature = 0; byte humidity = 0; int err = SimpleDHTErrSuccess; if ((err = dht11.read(&temperature, &humidity, NULL)) != SimpleDHTErrSuccess) { Serial.print("Read DHT11 failed, err="); Serial.println(err);delay(1000); return; } Serial.print("Sample OK: "); Serial.print((int)temperature); Serial.print("degC / "); Serial.print((int)temperature*1.8+32); Serial.print("degF, "); Serial.print((int)humidity); Serial.println("% RH"); delay(1500); } |
Run Arduino Code


Testing the DHT11 Sensor
I tested the DHT11 temperature and humidity sensor by integrating it with a 1602 LCD and placing the sensor under different conditions. One was next to my thermostat, and the other was next to a pot of boiling water.


Components used in this example
*As an Amazon & Ebay Associate I earn from qualifying purchases.
Component | Link |
Arduino UNO | https://amzn.to/3uYVAMC https://ebay.us/veZdKX |
DHT11 | https://amzn.to/3ttK6Ar https://ebay.us/ZEIZZJ |
1602 LCD | https://amzn.to/2P146LY https://ebay.us/sofDTP |
Breadboard (Elenco 9440) | https://amzn.to/3x23dnq https://ebay.us/FcwSdb |