#include <DHT.h>;
// Pin definitions
#define DHTPIN 7 // DHT22 data pin
#define DHTTYPE DHT22 // DHT22 sensor type
#define LM35PIN A0 // LM35 analog pin
// Initialize DHT sensor
DHT dht(DHTPIN, DHTTYPE);
void setup() {
// Begin serial communication at 9600 baud rate
Serial.begin(9600);
// Initialize DHT sensor
dht.begin();
}
void loop() {
// Read DHT data
float hum = dht.readHumidity();
float tempDHT = dht.readTemperature();
// Print DHT data
Serial.print("DHT Humidity: ");
Serial.print(hum);
Serial.print(" %, DHT Temperature: ");
Serial.print(tempDHT);
Serial.println(" Celsius");
// Read LM35 data
int reading = analogRead(LM35PIN);
// Convert reading into voltage
float voltage = reading * (5.0 / 1024.0);
// Convert voltage into temperature in Celsius
float tempLM35 = voltage * 100;
// Print LM35 data
Serial.print("LM35 Temperature: ");
Serial.print(tempLM35);
Serial.print("\xC2\xB0C | ");
// Convert Celsius to Fahrenheit
float tempLM35F = (tempLM35 * 9.0 / 5.0) + 32.0;
Serial.print(tempLM35F);
Serial.println("\xC2\xB0F");
// Delay before next reading
delay(10000); // 10 seconds
}