diff options
| author | Gustavoeklund01 <eklundgu@gmail.com> | 2025-10-19 10:42:54 -0300 |
|---|---|---|
| committer | Gustavoeklund01 <eklundgu@gmail.com> | 2025-10-19 10:42:54 -0300 |
| commit | 72bc657b9647f9dd679015d60956b9bc9a3289f5 (patch) | |
| tree | 8e240874c050c782824a76259ee06652e336e949 | |
| parent | 419767aab393a1a26b963f7a918545bb98bdbc74 (diff) | |
código dos sensores, luz, temperatura e humidade
| -rw-r--r-- | esp/BH1750.ino | 0 | ||||
| -rw-r--r-- | esp/DHT11.ino | 26 |
2 files changed, 26 insertions, 0 deletions
diff --git a/esp/BH1750.ino b/esp/BH1750.ino new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/esp/BH1750.ino diff --git a/esp/DHT11.ino b/esp/DHT11.ino new file mode 100644 index 0000000..e0f0342 --- /dev/null +++ b/esp/DHT11.ino @@ -0,0 +1,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); +}
\ No newline at end of file |
