#include "DHT.h"
DHT dht(2, DHT22); // funcao DHT passa parametros para dht.begin e para as linhas dht.read... que sao comandos da DHT lib,
void setup()
{
Serial.begin(9600);
Serial.println(F("DHTxx test!"));
dht.begin();
}
void loop()
{
delay(2000);
float h = dht.readHumidity(); // Read temperature as Celsius (the default)
float t = dht.readTemperature(); // Read humidity as Celsius (the default)
if (isnan(h) || isnan(t) ) // Check if any reads failed and exit early (to try again).
{
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
Serial.print(F("Humidity: "));
Serial.print(h);
Serial.print(F("% Temperature: "));
Serial.print(t);
Serial.println(F("°C "));
}