#include <LiquidCrystal_I2C.h>
#include "DHTesp.h"
const int DHT_PIN = 15;
DHTesp dhtSensor;
LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27, 16 column and 2 rows
void setup() {
lcd.init(); // initialize the lcd
lcd.backlight();
dhtSensor.setup(DHT_PIN, DHTesp::DHT22);
}
void loop() {
lcd.clear(); // clear display
TempAndHumidity data = dhtSensor.getTempAndHumidity();
lcd.setCursor(0, 0); // move cursor to (0, 0)
lcd.print("Temp:" + String(data.temperature, 2) + "Celcus"); // 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(3000); // display the above for two seconds
}Loading
esp32-devkit-c-v4
esp32-devkit-c-v4