Why is the humidity sensor lcd output as nan?

I used the same chords and circuitry.
Why does "nan" come up?
I followed this link.
[아두이노] 온/습도 LCD에 표시하기 (tistory.com)

<
#include <DHT.h>
#define DHTPIN 2
#define DHTTYPE DHT22
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
DHT dht(DHTPIN, DHTTYPE);

LiquidCrystal_I2C lcd(0x27,16,2);
float hum;
float temp;

void setup() {
Serial.begin(9600);
dht.begin();
delay(2000);
lcd.init();
lcd.backlight();
lcd.setCursor(2,0);
delay(5000);
lcd.clear();
}

void loop() {
hum = dht.readHumidity();
temp= dht.readTemperature();

Serial.print("HUMIDITY: ");
Serial.print(hum,0);
Serial.print(" %, TEMPERATURE: ");
Serial.print(temp, 1);
Serial.println(" C");
lcd.setCursor(0,0);
lcd.print("TEMP:");

float t = temp;
lcd.print(t,1);
lcd.print(" C");
lcd.setCursor(0,1);
lcd.print("HUMIDITY:");
int h = hum;
lcd.print(h);
lcd.print(" % ");
lcd.println();
delay(2000);
}
/>

Hello
I gues the sensor is not working.
Make a re-check of the sensor wiring.

Thank you, but the same error occurred when I changed the sensor.
The sensor wiring is the same, but there's still an error......

Still this.

'Not working' doesn't necessarily mean it's broken. In 99.9% of the cases, it's because you're not using it right.

How can i use this senser successfully?

What sensor do you use?
How have you connected it?

Hello,
you may check the WWW for a step by step tutorial for this sensor.

I used a DHT11 sensor.
I connected it exactly like that link.

Are the temperatures that you read from the sensor correct?

I'm not sure. What's www?
You means internet?

your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with your project :wink: See About the Installation & Troubleshooting category.

Can you please edit your post, select all code and click the </> button to apply code tags and next save your post. It makes it easier to read, easier to copy and prevents the forum software from incorrect interpretation of the code.

Thank you!

You mention using a DHT 11 in your post here but your code reflects using a #define DHTTYPE DHT22. Here is how I set my code up:

// Uncomment whatever DHT type you're using!
#define DHTTYPE DHT11   // DHT 11 
//#define DHTTYPE DHT22   // DHT 22  (AM2302)
//#define DHTTYPE DHT21   // DHT 21 (AM2301)

The above example would be for using a DHT 11. When I uncomment the DHT 22 and use a DHT 11 I just get bogus numbers but I do get a number. Anyway you may want to look at that.

Ron