Arduino Uno connect to DHT 11 sensor but LCD do not display value of temperature and humidity

#include <dht.h>
#include <LiquidCrystal.h>
dht DHT;
LiquidCrystal lcd(11, 12, 5, 4, 3, 2);
#define DHT11_PIN 7
void setup(){
 Serial.begin(9600);
 lcd.begin(16, 2);
}
void loop(){
 int chk = DHT.read11(DHT11_PIN);

 Serial.print("Temperature = ");
 Serial.print(DHT.temperature);
 Serial.write(0xC2);
 Serial.write(0xB0);
 Serial.print("C ");
 Serial.print("Humidity = ");
 Serial.print(DHT.humidity);
 Serial.write(0x25);
 Serial.println("");

 lcd.setCursor(0,0);
 lcd.print("Temp: ");
 lcd.print(DHT.temperature*9/5+32);
 lcd.print((char)223);
 lcd.print("F");
 lcd.setCursor(0,1);
 lcd.print("Humidity: ");
 lcd.print(DHT.humidity);
 lcd.print("%");

 delay(2000);
}

hardware connected:CH340 driver.
My LCD display do not show the value of temperature and humidity. It shows temperature= C and humidity = %.
Serial monitor show temperature = 0C and humidity show 0%

I'm not sure; maybe it should be

Serial.print(DHT.humidity());

Look at the examples that come with the DHT library that you use. Which DHT library do you use?

1 Like

DHTlib by Rob Tillaart

OK, it's not humidity() or temperature() so your code was OK from that perspective.

Print the value of the chk variable to see if the reading was successful before printing temperature and humidity.

It looks like your code is correct.

It works in the simulator, although the simulator does not have DHT11, I used DHT22
which is similar to DHT11.

There is probably a connection error or your DHT11 is defective.

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