#include <DHT.h>
#include <DHT_U.h>
// DHT11 Sensor
#define DHTPIN 4
#define DHTTYPE DHT11 // DHT22
DHT dht(DHTPIN, DHTTYPE);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
// DHT11
dht.begin();
}
void loop() {
// put your main code here, to run repeatedly:
float h = dht.readHumidity(); //습도읽기
float t = dht.readTemperature(); // 섭씨 온도를 읽기
float f = dht.readTemperature(true); // 화씨온도를 읽기
// Sensor error chk
if(isnan(h) || isnan(t) || isnan(f))
{
Serial.println(F("Sensor ERROR"));
}
// 사람이 느끼는 체감온도를 화씨로 표시함
float hif = dht.computeHeatIndex(f, h);
// 사람이 느끼는 체감온도를 섭씨로 표시함
float hic = dht.computeHeatIndex(t, h, false);
// 콘솔출력
// Data 출력
Serial.print(F("Hum = "));
Serial.print(h);
Serial.print(F("%, Temp = "));
Serial.print(t);
Serial.print(F("℃ "));
// 열지수 측정
Serial.print(F("°F Heat index: "));
Serial.print(hic);
Serial.print(F("°C "));
Serial.print(hif);
Serial.println(F("°F 입니다요.."));
delay(500);
}