#include <DHT.h>
#define DHTPIN 3
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); // permite visualizar o cargar los valores
dht.begin();
}
void loop() {
// put your main code here, to run repeatedly:
float humedad = dht.readHumidity();
float temperatura = dht.readTemperature();
if (isnan(humedad) || isnan(temperatura)){
Serial.println("Fallo al leer el sensor");
}
Serial.print("Humedad: ");
Serial.println(humedad);
Serial.print("Temperatura: ");
Serial.println(temperatura);
delay(500);
}