#include <DHT.h>
#define DHTPIN 5
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
delay(2000);
float humidity = dht.readHumidity();
float temperature = dht.readTemperature();
float temperatureBul = dht.readTemperature(true);
if (isnan(humidity) || isnan(temperature)) {
Serial.println("Error al leer el sensor DHT!");
return;
}
float hif = dht.computeHeatIndex(temperatureBul, humidity);
float hic = dht.computeHeatIndex(temperature, humidity);
Serial.print("Humedad: ");
Serial.print(humidity);
Serial.print("%\t");
Serial.print("Temperatura: ");
Serial.print(temperature);
Serial.print("°C\t");
Serial.print("Indice de calor: ");
Serial.print(hic);
Serial.print("°C\t");
Serial.print(hif);
Serial.println("°F");
}