#include <LiquidCrystal_I2C.h>
#include <DHT.h>
// what pin we're connected to
#define DHTPIN 6
// DHT 22 (AM2302)
#define DHTTYPE DHT22
//// Initialize DHT sensor for normal 16mhz Arduino
DHT dht(DHTPIN, DHTTYPE);
// I2C address 0x27, 16 column and 2 rows
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int LED = 5;
const int BZR = 4;
//float h; //Stores humidity value
float t; //Stores temperature value
void setup(void)
{
dht.begin();
Serial.begin(9600);
lcd.init(); // initialize the lcd
lcd.backlight();
pinMode(LED, OUTPUT);
pinMode(BZR, OUTPUT);
}
void loop(void)
{
digitalWrite(LED, LOW);
digitalWrite(BZR, LOW);
lcd.clear(); // clear display
t= dht.readTemperature(); // Read temperature
// h = dht.readHumidity(); // Read humidity
if(t >= 35.00){
digitalWrite(LED, HIGH);
digitalWrite(BZR, HIGH);
lcd.setCursor(0, 0); // move cursor to (0, 0)
lcd.print("Temp.: ");
lcd.print(t);
lcd.print((char)223); //shows degrees character
lcd.print("C");
lcd.setCursor(4,1);
lcd.print("WARNING!!! ");
delay(1000); // display the above for 1 second
//print the temperature in Celsius
Serial.print("Temperature: ");
Serial.print(t);
Serial.print((char)176);//shows degrees character
Serial.print("C | ");
Serial.println("WARNING");
}
else{
lcd.setCursor(0, 0); // move cursor to (0, 0)
lcd.print("Temp.: ");
lcd.print(t);
lcd.print((char)223); //shows degrees character
lcd.print("C");
lcd.setCursor(0,1);
lcd.print("Fhrt.: ");
lcd.print((t * 9.0) / 5.0 + 32.0);
lcd.print((char)223); //shows degrees character
lcd.print("F");
delay(1000); // display the above for 1 second
//print the temperature in Celsius
Serial.print("Temperature: ");
Serial.print(t);
Serial.print((char)176);//shows degrees character
Serial.print("C | ");
//print the temperature in Fahrenheit
Serial.print((t * 9.0) / 5.0 + 32.0);
Serial.print((char)176);//shows degrees character
Serial.println("F");
//delay(500);
}
}