#include <DHT.h>
#include <LiquidCrystal_I2C.h>
#define DHT22_PIN 23 // ESP32 pin GPIO23 connected to DHT22 sensor
LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27 (from DIYables LCD), 16 column and 2 rows
DHT dht22(DHT22_PIN, DHT22);
void setup() {
dht22.begin(); // initialize the DHT22 sensor
lcd.init(); // initialize the lcd
lcd.backlight(); // open the backlight
}
void loop() {
float humi = dht22.readHumidity(); // read humidity
float tempC = dht22.readTemperature(); // read temperature
lcd.clear();
// check whether the reading is successful or not
if (isnan(tempC) || isnan(humi)) {
lcd.setCursor(0, 0);
lcd.print("Failed");
} else {
lcd.setCursor(0, 0); // display position
lcd.print("Temp: ");
lcd.print(tempC); // display the temperature
lcd.print(" C");
lcd.setCursor(0, 1); // display position
lcd.print("Humi: ");
lcd.print(humi); // display the humidity
lcd.print("%");
}
// wait a 2 seconds between readings
delay(2000);
}
esp:0
esp:2
esp:4
esp:5
esp:12
esp:13
esp:14
esp:15
esp:16
esp:17
esp:18
esp:19
esp:21
esp:22
esp:23
esp:25
esp:26
esp:27
esp:32
esp:33
esp:34
esp:35
esp:3V3
esp:EN
esp:VP
esp:VN
esp:GND.1
esp:D2
esp:D3
esp:CMD
esp:5V
esp:GND.2
esp:TX
esp:RX
esp:GND.3
esp:D1
esp:D0
esp:CLK
dht1:VCC
dht1:SDA
dht1:NC
dht1:GND
lcd1:GND
lcd1:VCC
lcd1:SDA
lcd1:SCL