DHT11 sensor showing -999.00 humidity and temperature

I tried to make a program that will turn the heater on and off depending on the room temperature and the desired room temperature. The first step was to connect the DHT11 sensor to an Arduino and an LCD display that will show the temperature and humidity. I followed a video named " How to Set Up the DHT11 Humidity and Temperature Sensor on an Arduino" by Circuit Basics (couldn't put the link because it doesn't allow me to) with the help of this site "Arduino DHT11 setup" to set up the DHT11 sensor and this site "Arduino LCD display setup" to set up the LCD display. The wiring diagram can be found in the link "Arduino LCD display setup" with the DHT11 being connected to pin 7.

Code:

#include <LiquidCrystal.h>
#include <dht.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

dht DHT;

#define DHT11_PIN 7    

void setup(){
  lcd.begin(16, 2);
}

void loop(){
  int chk = DHT.read11(DHT11_PIN);
  lcd.setCursor(0,0); 
  lcd.print("Temp: ");
  lcd.print(DHT.temperature);
  lcd.print((char)223);
  lcd.print("C");
  lcd.setCursor(0,1);
  lcd.print("Humidity: ");
  lcd.print(DHT.humidity);
  lcd.print("%");
  delay(1000);
}


You can see 2 potentiometers in the picture. The potentiometer connected to A1 now does nothing, the other is to adjust the contrast of the text on the LCD display.

int chk = DHT.read11(DHT11_PIN);

What does this function call do and what does it return ?

Here is a clue from the library

// return values:
// DHTLIB_OK
// DHTLIB_ERROR_CHECKSUM
// DHTLIB_ERROR_TIMEOUT
int dht::read11(uint8_t pin)

and

#define DHTLIB_OK 0
#define DHTLIB_ERROR_CHECKSUM -1
#define DHTLIB_ERROR_TIMEOUT -2
#define DHTLIB_INVALID_VALUE -999

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.