Is my DHT11 broken?

For context:

I have used the DHT11 last month and it was working very fine. I stopped using it for almost 2 weeks and just today, when I tried to use it again with the same code that I used, it only shows "nan" on the LCD. I tried using different code, but the serial monitor only showed zero. I tried another code that I found online, however, the serial monitor showed -999 on both temperature and humidity.

Extra info:

  • LCD is i2C
  • already tried to disconnect, connect, and change jumpers
  • Do you have a pull-up resistor on the DHT11 ?

Always show us a good schematic of your proposed circuit.
Show us good images of your ‘actual’ wiring.
Give links to components.

1 Like

here's the photo of my set up

and here's the code

#include <Wire.h>
#include <DHT.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,  16, 2);

#define DHTPIN 7
#define DHTTYPE DHT11

int relay1 = 3;
int relay2 = 4;

DHT dht(DHTPIN, DHTTYPE);

void setup() {

Serial.begin(9600);

pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);

dht.begin();

lcd.init();
lcd.clear();
lcd.backlight();

}

void loop() {

  one();
//relay and motion connection
  delay(2000);
  }
  void one() {
    float dhtHumidity = dht.readHumidity();
    float dhtTemperature = dht.readTemperature();

    delay(1000);

  lcd.setCursor(0,0);

  lcd.print("Temp: ");
  lcd.print(dhtTemperature);
  lcd.print(" C");

  lcd.setCursor(0,1);
  lcd.print("Humid: ");
  lcd.print(dhtHumidity);
  lcd.print(" H");
}




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