#include "DHT.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define DHTPIN 12
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
// LCD I2C (address 0x27 or 0x3F depending on your module)
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup()
{
Serial.begin(9600);
Serial.println(F("Group 1 - DHT22"));
pinMode(13, INPUT);
dht.begin();
// Initialize I2C LCD
lcd.init();
lcd.backlight();
lcd.print("ESP32 System");
}
void loop() {
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
int M = analogRead(13);
int G = map(M,0,4095,0,100);
Serial.print("The Gas Value is : ");
Serial.print(G);
Serial.println("%");
Serial.print("The temperature is : ");
Serial.println(t);
Serial.print("The Humidity is : ");
Serial.println(h);
lcd.clear();
lcd.print("Temp : ");
lcd.print(t);
delay(500);
lcd.clear();
lcd.print("Hum : ");
lcd.print(h);
delay(500);
lcd.clear();
lcd.print("Gas : ");
lcd.print(G);
lcd.print("%");
delay(500);
}