Temperature not reading correctly.

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

void setup() {
  pinMode(DHT11_PIN, INPUT);
  Serial.begin(9600);
}

void loop() {
  int chk = DHT.read11(DHT11_PIN);
  Serial.print(DHT.temperature);
  Serial.print(" deg C");
  Serial.print("\t");
  Serial.print(DHT.humidity);
  Serial.println(" % humidity");
  delay(1000);
}

The Serial display shows

29.00 deg C	71.00 % humidity
-999.00 deg C	-999.00 % humidity
29.00 deg C	71.00 % humidity
-999.00 deg C	-999.00 % humidity
29.00 deg C	71.00 % humidity
-999.00 deg C	-999.00 % humidity
29.00 deg C	71.00 % humidity
-999.00 deg C	-999.00 % humidity
29.00 deg C	71.00 % humidity
-999.00 deg C	-999.00 % humidity

I tried to use the DHT11 tutorial.
There seems to be a few errors in the reading.

  1. The temperature is always at 29.00 deg no matter how I tried to raise it.
  2. there will be a -999.00 deg C reading and -999.00 % humidity reading every 2 seconds.
  3. If I set my delay to 2000, it will only shows 29.00 deg C and the correct humidity reading.
    Please help out a newbie.

Hi there,

I am also a newbie but I have recently put this sensor to work.

My first question would be: do you have the 3 or the 4 pin version? Remember that the 4 pin version requires a resistor (the 3 pin one has one built-in).

I also got this issue when the cables were loose (for example, not connected to a bread board).

Remember that this sensor has a temperature accuracy of +-2 C when you are testing raising the temperature and a delay of 1 sec minimum between readings.

I found everything to be well explained in this tutorial. He also shows how to attach an LCD and make it work with the sensor, which I assume is your next step.

http://www.circuitbasics.com/how-to-set-up-the-dht11-humidity-sensor-on-an-arduino/

I hope it helps, but I am also a newbie here.

mine is the 3 pin type. I used the same tutorial as yours. I've just check all my connections and it seems fully secured. But the code still do not work

This sensor can produce no more than one reading every 2 seconds. You try to read every second. That's your first problem.

The temperature reading, I don't know. Hold it against your body under your clothes and you should get up to 32-34°C. Place it in the fridge (wires under the door seal) and it should go down to 3-6°C.