DH11 sensor -999.00 problem

Using this sensor I keep getting every second temperature and humidity output to the serial monitor as -999.00. Then in between it prints them correctly. ie 27C and 62%. I tried increasing the delay to 9000 but this did not get rid of the problem. Does anyone know why this happens?

Post your code. Read the how to use this forum sticky to see how to post code.

This is the code I am using.......

#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);
}

Hi retired0903,

I do not trust your library <dht.h>. Use another library - there are several DHT libraries.
Further, output of the DHT should be stored in a float type variable.

Try the following sketch. It uses <DHT.h>

// single DHT 11 temp-humidity sensor on Arduino with serial monitor reporting only
// original written by Tim Stephens 2013 -  http://www.tjstephens.com/blog/2013/11/23/temperature-logger/
// public domain
// modified Photoncatcher March 25, 2020 but.....

// based on DHT11 examples by Ladyada.
// data pin of DHT11 sensors wired to pin 10 on Arduino
// 10k pull up resistor (between data and 5V)

   #include "DHT.h"

   float h, t;
   DHT DHT_sens(7, DHT11);           //datapin sensor to pin 4 Arduino


void setup()
{

   DHT_sens.begin();

   Serial.begin (9600);
   Serial.println ("================================================");
   Serial.println ("Bare DHT11 temp-humidity sensor - March 25, 2020");
   Serial.println ("================================================");
   Serial.println (" ");
}


void loop(){


   
// ================== read from buffer and display =========================   
   
   h = DHT_sens.readHumidity();
   t = DHT_sens.readTemperature();

 
   delay (1000);                       // pause a second
   Serial.print ("Humidity: ");
   Serial.print (h,0);                  // zero decimal
   Serial.print (" %\t");
   Serial.print ("Temperature: ");
   Serial.print (t,1);                  // one decimal
   Serial.println (" *C");
   delay (1000);                       // pause a second

}

I used your sketch but the serial monitor output is the same

I have tried several dht.h's with no change in the output.

Could there be a problem with the sensor.

Maybe I should try a DH22.

Problem solved. It was a wrong DHT library.