Problem with DHT11

Hello. I am using a DHT11 sensor to measure temperature and humidity, but it doesn’t work. Sometimes it shows the correct values, sometimes it shows -999 for both temperature and humidity. I posted my circuit and code below:

#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 = ");


You need a 10k pull-up resistor to Vcc for the data signal.

Believe there is a 10k PU resistor on the left side of the DHT11 PCB.

We need to see OP’s actual wiring image.