How to connect DHT 11 With Arduino||DHT11 Sensor Module with Arduino Temperature and Humidity

preview_player
Показать описание
Code :
#include "DHT.h"

#define DHTPIN 2 // what pin we're connected to

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

// Initialize DHT sensor for normal 16mhz Arduino
DHT dht(DHTPIN, DHTTYPE);

void setup() {

}

void loop() {
// Wait a few seconds between measurements.
delay(2000);

// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
// Read temperature as Celsius
// Read temperature as Fahrenheit

// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
return;
}

// Compute heat index
// Must send in temp in Fahrenheit!

}
Рекомендации по теме
Комментарии
Автор

Thank you very much for such amazing content. It seriously helps beginners like me

ahlamrafeek
Автор

its displays failed to read from dht sensor ...how to recitfy it sir

SUBAHARENIB
Автор

A problem is occurring, error: #include expects "FILENAME" or you have any idea?

ankushghosh