#include <DHT.h>
#define DHTPIN 3
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
void setup() {
// put your setup code here, to run once:
dht.begin();
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
delay(2000);
float h = dht.readHumidity();
float c = dht.readTemperature();
float f = dht.readTemperature(true);
if(isnan(h) || isnan(c) || isnan(f)){
Serial.println("DHT Gagal Membaca !!");
return;
}
float hic = dht.computeHeatIndex(c, h, false);
float hif = dht.computeHeatIndex(f, h);
Serial.print("Humidity : ");
Serial.print(h);
Serial.print("% ");
Serial.print("Temperature : ");
Serial.print(c);
Serial.print("c ");
Serial.print(f);
Serial.println("F ");
Serial.print("Heat index : ");
Serial.print(hic);
Serial.print("c ");
Serial.print(f);
Serial.println("F ");
}