My dht11 with i2c lcd screen is showing 0 temp and 0 humidity

I am new to this idk why it wont work
`//* How to use the DHT-11 sensor with Arduino
// Temperature and humidity sensor and
// I2C LCD1602
// SDA --> A4
// SCL --> A5

//Libraries
#include <DHT.h>;
//I2C LCD:
#include <LiquidCrystal_I2C.h>
#include <Wire.h>

LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display

//Constants
#define DHTPIN 7 // what pin we're connected to
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino

//Variables
//int chk;
int h; //Stores humidity value
int t; //Stores temperature value

void setup()
{
Serial.begin(9600);
Serial.println("Temperature and Humidity Sensor Test");
dht.begin();
lcd.init(); //initialize the lcd
lcd.backlight(); //open the backlight
}

void loop()
{
//Read data and store it to variables h (humidity) and t (temperature)
// Reading temperature or humidity takes about 250 milliseconds!
h = dht.readHumidity();
t = dht.readTemperature();

//Print temp and humidity values to serial monitor
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %, Temp: ");
Serial.print(t);
Serial.println(" ° Celsius");

// set the cursor to (0,0):
// print from 0 to 9:

lcd.setCursor(0, 0);
lcd.println(" Now Temperature ");

lcd.setCursor(0, 1);
lcd.print("T:");
lcd.print(t);
lcd.print("C");

lcd.setCursor(6, 1);
lcd.println("2020 ");
 
lcd.setCursor(11, 1);
lcd.print("H:");
lcd.print(h);
lcd.print("%");

delay(1000); //Delay 1 sec.
}`

Please edit your post to add code tags, links to the components and a wiring diagram.

Posting instructions are in the "How to get the best out of this forum" post.

Hint: always test the individual components (like the LCD alone) using one or more of the examples in the device libraries, before doing anything else.

Your code is working correctly.
I tested it on the Wokwi simulator.
Post a schematic of your project, as there must be either a connection error or your sensor is defective.

https://github.com/passion-tech/Hello-tech/blob/master/Dht%2011%20module%20with%20LCD%20display_bb.png I used this one

Are you using a module with DHT11 or just DHT11?
If it's the module, it already comes with the resistor, but if it's the solitary DHT11 you need to include the resistor.

Module:


look 10 k resistor (R1).

Or No module:

image
Look the 10K resistor.

i am using the module it only has 3 pins

So I believe your sensor is damaged.

ive never even used it i js bought it

Seems like it is a damaged sensor or a wiring issue. Post a clear photo of your actual build showing all the wire connections.

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