#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define DHTTYPE DHT22 // DHT 22 sensor
#define DHTPIN 2 // Digital pin connected to the DHT sensor
DHT dht(DHTPIN, DHTTYPE); // Initialize the DHT sensor
LiquidCrystal_I2C lcdTemp(0x27, 16, 2); // Initialize the temperature LCD with I2C address 0x27, 16 columns and 2 rows
LiquidCrystal_I2C lcdHum(0x26, 16, 2); // Initialize the humidity LCD with I2C address 0x26, 16 columns and 2 rows
void setup() {
Serial.begin(9600); // Start the serial communication at 9600 baud rate
dht.begin(); // Start the DHT sensor
lcdTemp.begin(16, 2); // Start the temperature LCD
lcdHum.begin(16, 2); // Start the humidity LCD
lcdTemp.backlight(); // Turn on the backlight for temperature LCD
lcdHum.backlight(); // Turn on the backlight for humidity LCD
}
void loop() {
float temperature = dht.readTemperature(); // Read the temperature from the DHT sensor
float humidity = dht.readHumidity(); // Read the humidity from the DHT sensor
// Display the temperature on the temperature LCD
lcdTemp.setCursor(0, 0); // Set the cursor position on the first row and first column
lcdTemp.print("Temperature: ");
lcdTemp.print(temperature);
lcdTemp.print("C");
// Display the humidity on the humidity LCD
lcdHum.setCursor(0, 0); // Set the cursor position on the first row and first column
lcdHum.print("Humidity: ");
lcdHum.print(humidity);
lcdHum.print("%");
delay(1000); // Wait for 1 second before taking another reading
}