#include <OneWire.h>
#include <DallasTemperature.h>
#include <DHT.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
const int dhtPin = 2; // Digital pin for the DHT22 sensor
const int lcdColumns = 20; // Number of columns in your LCD
const int lcdRows = 4; // Number of rows in your LCD
DHT dht(dhtPin, DHT22); // Create a DHT object for the DHT22 sensor
LiquidCrystal_I2C lcd(0x27, lcdColumns, lcdRows); // Change the address if needed
const int temperatureThreshold = 30; // Adjust the temperature threshold based on your needs
void setup() {
Serial.begin(9600);
dht.begin(); // Initialize the DHT22 sensor
lcd.begin(lcdColumns, lcdRows); // Initialize the LCD screen
lcd.print("Room Temperature Sensing");
delay(2000);
lcd.clear();
}
void loop() {
float humidity = dht.readHumidity();
float temperatureC = dht.readTemperature();
lcd.setCursor(0, 0);
lcd.setCursor(0, 1);
lcd.print("Temp:");
lcd.print(temperatureC);
lcd.print(" C");
String msg = temperatureC > 35 ? "HOT" : temperatureC < 15 ? "COLD" : "OK";
Serial.print("Temperature: ");
Serial.print(temperatureC);
Serial.println("°C");
delay(500);
Serial.print("The climate is ");
Serial.println(msg);
delay(500);
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.println("%");
delay(1000);
}