#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>
// Pin Definitions
#define DHTPIN 4 //
#define I2C_SDA 21
#define I2C_SCL 22
DHT dht(DHTPIN, DHT22);
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
Serial.begin(115200);
dht.begin();
lcd.init();
lcd.backlight();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Air Quality Monitoring");
}
void loop() {
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
// Simulate gas value (replace with your logic)
int gasValue = random(0, 2000); // Simulate random gas values
// Display temperature and humidity on LCD
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(temperature);
lcd.print(" C");
lcd.setCursor(0, 1);
lcd.print("Humidity: ");
lcd.print(humidity);
lcd.print("%");
lcd.setCursor(0, 0);
lcd.print("Gas Level: ");
lcd.print(gasValue);
if (gasValue < 300) {
lcd.setCursor(0, 0);
lcd.print("Gas Level: Good");
} else if (gasValue < 800) {
lcd.setCursor(0, 0);
lcd.print("Gas Level: Moderate");
} else {
lcd.setCursor(0, 0);
lcd.print("Gas Level: High");
}
delay(6000);
lcd.clear();
}