#include <LiquidCrystal_I2C.h> // Library for LCD with I2C interface
#include "DHTesp.h" // Library of DHT Sensor for ESP32/8266 NodeMCU

// I2C address 0x27, 16 column and 2 rows
LiquidCrystal_I2C lcd(0x27, 16, 2);

const int DHTpin = 23;
DHTesp dht;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  lcd.init();       // initialize the lcd
  lcd.backlight();  // on the lcd backlight 
  dht.setup(DHTpin, DHTesp::DHT22); // DHT11 
}

void loop() {
  // put your main code here, to run repeatedly:
  TempAndHumidity data = dht.getTempAndHumidity(); 
  lcd.clear();                                              // clear display
  lcd.setCursor(0, 0);                                      // move cursor to   (0, 0)
  lcd.print("Humidity: " + String(data.humidity, 1) + "%"); // print message at (0, 0)
  lcd.setCursor(0, 1);                                      // move cursor to   (0, 1)
  lcd.print("Temp: " + String(data.temperature, 2) + "°C"); // print message at (0, 1)  
  delay(1000);                                              // this speeds up the simulation

}