user37458: 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(){
   Serial.begin(9600);
}

void loop()
{
    int chk = DHT.read11(DHT11_PIN);
    Serial.print("Temperature = ");
    Serial.println(DHT.temperature);
    Serial.print("Humidity = ");
    Serial.println(DHT.humidity);
    delay(1000);
}

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




user45882: 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.

user-1: You have to call the functions:
#include <DHT.h>
#define DHT11_PIN 7
DHT dht(DHT11_PIN, DHT11);

void setup() {
    Serial.begin(9600);
    dht.begin();
}

void loop() {

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

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

    Serial.print("Temperature = ");
    Serial.println(temperature);
    Serial.print("Humidity = ");
    Serial.println(humidity);

    delay(1000);
}

Edit


37458: <p>I am trying to use DHT11 sensor with Arduino. But unfortunately it is returning following values:</p>

<p>Temperature = 1.00
Humidity = 2.00</p>

<p>My code is as follows:</p>

<pre><code>#include &lt;dht.h&gt;
dht DHT;
#define DHT11_PIN 7

void setup(){
   Serial.begin(9600);
}

void loop()
{
    int chk = DHT.read11(DHT11_PIN);
    Serial.print("Temperature = ");
    Serial.println(DHT.temperature);
    Serial.print("Humidity = ");
    Serial.println(DHT.humidity);
    delay(1000);
}
</code></pre>

<p>Link to the library I am using is <a href="https://drive.google.com/file/d/0B1paTI5fzcHodno5azFOSVVDT0E/view" rel="nofollow noreferrer">here</a></p>

<p>I have connected +ve to 3.3 V
I have connected -ve to Ground
I have connected out to digital pin # 7</p>

<p><a href="https://i.stack.imgur.com/29Geb.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/29Geb.jpg" alt="enter image description here"></a>
<a href="https://i.stack.imgur.com/PRsvr.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PRsvr.jpg" alt="enter image description here"></a>
<a href="https://i.stack.imgur.com/JlmVP.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JlmVP.jpg" alt="enter image description here"></a></p>
 45882: <p>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.</p>

<p>EDIT : on your pictures the white case says AM2302, it's definitely a DHT22 the code must be adapted accordingly.</p>
 -1: <p>You have to call the <strong>functions</strong>:</p>

<pre><code>#include &lt;DHT.h&gt;
#define DHT11_PIN 7
DHT dht(DHT11_PIN, DHT11);

void setup() {
    Serial.begin(9600);
    dht.begin();
}

void loop() {

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

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

    Serial.print("Temperature = ");
    Serial.println(temperature);
    Serial.print("Humidity = ");
    Serial.println(humidity);

    delay(1000);
}
</code></pre>

<p><strong>Edit</strong></p>

<p><a href="https://i.stack.imgur.com/iDuou.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iDuou.png" alt="enter image description here"></a></p>
