#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Initialize the LCD, adjust address (0x27) if needed
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Define MQ-135 sensor pins
const int mq135_before = A0;
const int mq135_after = A1;
void setup() {
// Initialize LCD
lcd.begin(16,2);
lcd.backlight();
// Initialize serial communication
Serial.begin(9600);
lcd.setCursor(0, 0);
lcd.print("Air Quality");
lcd.setCursor(0, 1);
lcd.print("Monitoring...");
delay(2000);
lcd.clear();
}
void loop() {
// Read sensor values
int sensorValueBefore = analogRead(mq135_before);
int sensorValueAfter = analogRead(mq135_after);
// Convert sensor values to PPM
float ppmBefore = sensorValueBefore * (5.0 / 1023.0) * 100; // Adjust multiplier for calibration
float ppmAfter = sensorValueAfter * (5.0 / 1023.0) * 100; // Adjust multiplier for calibration
// Display on LCD
lcd.setCursor(0, 0);
lcd.print("Before: ");
lcd.print(ppmBefore);
lcd.print(" PPM");
lcd.setCursor(0, 1);
lcd.print("After: ");
lcd.print(ppmAfter);
lcd.print(" PPM");
// Print to Serial Monitor
Serial.print("PPM Before: ");
Serial.print(ppmBefore, 2);
Serial.print(" | PPM After: ");
Serial.println(ppmAfter, 2);
delay(1000); // Update every second
}