blob: e0f0342ad3b3192f0b805abf9596d4d1c59ec4d6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#include "DHT.h"
#define DHTPIN 32
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(115200);
dht.begin();
Serial.println("Teste sensor DHT11 Temperatura e humidade");
}
void loop(){
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)){
Serial.println("ERRO de leitura");
return;
}
Serial.print("Humidade: ");
Serial.print(h);
Serial.print("% | Temperatura:");
Serial.print(t);
Serial.println(" °C");
delay(2000);
}
|