xxxxxxxxxx
int aqi = random(0, 500); // Simulating AQI value, replace with actual AQI sensor if available
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>
DHT dht(2, DHT11);
LiquidCrystal_I2C lcd(0x27, 16, 2); // Change 0x27 to your LCD's I2C address if necessary
void setup() {
lcd.begin();
lcd.backlight();
dht.begin();
pinMode(9, OUTPUT);
pinMode(10, INPUT);
Serial.begin(9600);
}
void loop() {
float temperature = dht.readTemperature(true); // Read temperature in Fahrenheit
float humidity = dht.readHumidity(); // Read humidity
int distance = getDistance(); // Get distance from ultrasonic sensor
if (isnan(temperature) || isnan(humidity)) {
lcd.setCursor(0, 0);
lcd.print("Sensor error");