#include "DHTesp.h"
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27, 16 column and 2 rows
const int DHT_PIN = 15;
DHTesp dhtSensor;
void setup()
{
lcd.init(); // initialize the lcd
lcd.backlight();
Serial.begin(115200);
dhtSensor.setup(DHT_PIN, DHTesp::DHT22);
}
void loop()
{
TempAndHumidity data = dhtSensor.getTempAndHumidity();
Serial.println("Temp: " + String(data.temperature, 2) + "oC");
Serial.println("Humidity: " + String(data.humidity, 1) + "%");
Serial.println("---");
delay(2000);
lcd.clear(); // clear display
lcd.setCursor(0, 0); // move cursor to (0, 0)
lcd.print("Temp: " + String(data.temperature, 2) + "oC"); // print message at (0, 0)
lcd.setCursor(0, 1); // move cursor to (2, 1)
lcd.print("Humidity: " + String(data.humidity, 1) + "%"); // print message at (2, 1)
delay(2000); // display the above for two seconds
}