#include <LiquidCrystal_I2C.h>
#include "DHTesp.h"
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int DHT_PIN = 15;
const int mq2pin = 35;
const int mq135pin = 33;
DHTesp dhtSensor;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, All");
lcd.init();
lcd.backlight();
lcd.print("hello guys!");
lcd.setCursor(2,0);
lcd.print("Industrial &");
lcd.setCursor(0,1);
lcd.print("Home Safety");
delay(2000);
// lcd.begin(16,2);
// lcd.print("MQ 2-Readings ");
// delay(2000);
lcd.clear();
dhtSensor.setup(DHT_PIN, DHTesp::DHT22);
}
void loop() {
TempAndHumidity data = dhtSensor.getTempAndHumidity();
Serial.println("Temp: " + String(data.temperature, 2) + "°C");
Serial.println("Humidity: " + String(data.humidity, 1) + "%");
Serial.println("---");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Temp: " + String(data.temperature, 2) + " C");
lcd.setCursor(0,1);
lcd.print("Humidity: " + String(data.humidity, 1) + "%");
delay(2000); // Wait for a new reading from the sensor (DHT22 has ~0.5Hz sample rate)
lcd.clear();
int mq2Value = analogRead(mq2pin);
Serial.println("MQ2 SENSOR VALUE- ");
Serial.println(mq2Value);
lcd.setCursor(0, 0); // Set cursor to the first line
lcd.print("MQ2 Gas Level: ");
lcd.setCursor(0, 1); // Set cursor to the second line
lcd.print(mq2Value); // Display the MQ-2 reading
delay(2000);
lcd.clear();
int mq135Value = analogRead(mq135pin);
Serial.println("MQ135 SENSOR VALUE: ");
Serial.println(mq135Value);
lcd.setCursor(0, 0); // Set cursor to the first line
lcd.print("MQ135 GaS Level: ");
lcd.setCursor(0, 1); // Set cursor to the second line
lcd.print(mq135Value); // Display the MQ-2 reading
delay(2000);
lcd.clear();
}