#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <DHTesp.h>
#define DHTPIN 15
DHTesp dhtSensor;
#define SDA 13
#define SCL 14
LiquidCrystal_I2C lcd(0x27,16,2);
void setup() {
Serial.begin(115200);
Wire.begin(13, 14);
lcd.begin(13, 14);
lcd.init();
lcd.backlight();
dhtSensor.setup(DHTPIN, DHTesp::DHT22);
pinMode(2, OUTPUT);
pinMode(4, OUTPUT);
}
void loop() {
//float h = dhtSensor.readHumidity();
//float t = dhtSensor.readTemperature();
TempAndHumidity data = dhtSensor.getTempAndHumidity();
Serial.println("Temp: " + String(data.temperature, 2) + "°C");
Serial.println("Humidity: " + String(data.humidity, 1) + "%");
Serial.println("---");
lcd.setCursor(0,0);
lcd.print("Temp");
lcd.setCursor(6,0);
lcd.print(data.temperature);
lcd.setCursor(12,0);
lcd.print("C");
lcd.setCursor(0,1);
lcd.print("Umid");
lcd.setCursor(6,1);
lcd.print(data.humidity);
lcd.setCursor(12,1);
lcd.print("%");
if (data.temperature > 25){
digitalWrite(2, HIGH);
}
else{
digitalWrite(2, LOW);
};
if (data.humidity > 60){
digitalWrite(4, HIGH);
}
else{
digitalWrite(4, LOW);
}
delay(2000);
}