PCEval / esp32 /level2 /humidity_sensor /src /main_esp.cpp
eunzee's picture
upload Arduino Uno and ESP32 project files
8e53a3e verified
Raw History Blame Contribute Delete
530 Bytes
/**
Read humidity sensor value and compare with the input value
03 MAY 2025 by Blind Author
*/
#include <Arduino.h>
#include "DHT.h"
#define DHTTYPE DHT22
#define DHTPIN 2
DHT dht(DHTPIN, DHTTYPE);
float threshold = 50.0;
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
float humidity = dht.readHumidity();
if (humidity < threshold) {
Serial.println("Humidity is below the threshold");
} else {
Serial.println("Humidity is above the threshold");
}
delay(1000);
}