#include <LiquidCrystal.h>
#include <DHT.h>
#define DHTPIN1 8 // Digital pin connected to the first DHT sensor
#define DHTPIN2 2 // Digital pin connected to the second DHT sensor
#define DHTTYPE DHT11 // DHT 11
DHT dht1(DHTPIN1, DHTTYPE);
DHT dht2(DHTPIN2, DHTTYPE);
int rs=12,en=11,d4=5,d5=4,d6=7,d7=6;
LiquidCrystal lcd(rs,en,d4,d5,d6,d7);
void setup() {
// Start serial communication
Serial.begin(9600);
// Start DHT sensors
dht1.begin();
dht2.begin();
// Set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Greenhouse Monitor");
}
void loop() {
// Read temperature and humidity from first DHT sensor
float h1 = dht1.readHumidity();
float t1 = dht1.readTemperature(); // Celsius
// Read temperature and humidity from second DHT sensor
float h2 = dht2.readHumidity();
float t2 = dht2.readTemperature(); // Celsius
// Read water level, soil moisture, and light
int waterLevel = readWaterLevel(); // Implement this function for water level sensor
int soilMoisture = analogRead(A0);
int lightLevel = analogRead(A1);
// Print to serial monitor for debugging
Serial.print("Sensor 1 - Humidity: ");
Serial.print(h1);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t1);
Serial.println(" *C");
Serial.print("Sensor 2 - Humidity: ");
Serial.print(h2);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t2);
Serial.println(" *C");
// Print to LCD
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Temp1: ");
lcd.print(t1);
lcd.print(" C ");
lcd.print("Humid1: ");
lcd.print(h1);
lcd.print("%");
lcd.setCursor(0, 1);
lcd.print("Temp2: ");
lcd.print(t2);
lcd.print(" C ");
lcd.print("Humid2: ");
lcd.print(h2);
lcd.print("%");
delay(2000); // Delay between measurements
}
int readWaterLevel() {
// Implement your water level sensor reading logic here
// Example:
// int waterLevel = analogRead(A2); // Replace A2 with your actual pin
// return waterLevel;
return 0; // Placeholder
}