I am trying to use DHT11 sensor with Arduino. But unfortunately it is returning following values:

Temperature = 1.00 Humidity = 2.00

My code is as follows:

#include <dht.h>
dht DHT;
#define DHT11_PIN 7

void setup(){

void loop()
    int chk = DHT.read11(DHT11_PIN);
    Serial.print("Temperature = ");
    Serial.print("Humidity = ");

Link to the library I am using is here

I have connected +ve to 3.3 V I have connected -ve to Ground I have connected out to digital pin # 7

enter image description here enter image description here enter image description here

  • Current temperature of the room otherwise is 34 degree celsius and 62% Humidity Aug 19, 2017 at 11:18

2 Answers 2


You have to call the functions:

#include <DHT.h>
#define DHT11_PIN 7
DHT dht(DHT11_PIN, DHT11);

void setup() {

void loop() {

    float humidity = dht.readHumidity();
    float temperature = dht.readTemperature();

   if (isnan(humidity) || isnan(temperature)) {
      Serial.println("Failed to read from DHT sensor!");

    Serial.print("Temperature = ");
    Serial.print("Humidity = ");



enter image description here

  • It seems that you are using a different library. Can you tell me which library are you using for this code? Aug 19, 2017 at 11:34
  • I'm using the Adafruit DHT library, here github.com/adafruit/DHT-sensor-library. I've been using it for more than a year; no complains.
    – user31481
    Aug 19, 2017 at 11:36
  • Serial.begin(9600); was missing so I added that in your code and I still get the same output as before. Temperature 1 and Humidity 2 Aug 19, 2017 at 11:45
  • @Saad. I tested the same sketch on my lab. It works, but sometimes the DHT act funny. Check connections, place a 4.7K resistor between Vcc and Data Line.
    – user31481
    Aug 19, 2017 at 13:49
  • Ahmm I am not quite good with circuits. So not sure if I am supposed to put one at both places or just use one resistor. And secondly I only have 10k resistors at the moment :O would they work? Aug 19, 2017 at 14:03

This is not a DHT11, DHT11 is blue, DHT21 is black, and DHT 22 is white. It must be a DHT22 hence the wrong values.

EDIT : on your pictures the white case says AM2302, it's definitely a DHT22 the code must be adapted accordingly.

  • I had the reverse problem: I used a DHT11 (blue one) instead of a dht22 (white one). The value I got were in the 500`C for the temperature and the 1500% for humidity. Replacing the DHT11 by the DHT22 solve it.
    – MagTun
    Dec 2, 2018 at 5:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.