#include "DHTesp.h"
#include <LiquidCrystal_I2C.h>
#define LED 12
const int DHT_PIN = 15;
int led_state = LOW;
DHTesp dhtSensor;
LiquidCrystal_I2C LCD = LiquidCrystal_I2C(0x27, 16, 2);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(LED, OUTPUT);
dhtSensor.setup(DHT_PIN, DHTesp::DHT22);
LCD.init();
LCD.backlight();
}
void loop() {
// put your main code here, to run repeatedly:
TempAndHumidity data = dhtSensor.getTempAndHumidity();
//Serial.println("Temp: " + String(data.temperature, 2) + "°C");
LCD.setCursor(0, 0);
LCD.println("Temp:");
LCD.setCursor(10, 0);
LCD.println(String(data.temperature, 2));
//Serial.println("Humidity: " + String(data.humidity, 1) + "%");
LCD.setCursor(0,1);
LCD.println("Humidity:");
LCD.setCursor(10, 1);
LCD.println(String(data.humidity, 1));
//Serial.println("---");
if(data.temperature <= 0 || data.temperature >= 50) digitalWrite(LED, HIGH);
else digitalWrite(LED, LOW);
delay(500);
}