#include <LiquidCrystal_I2C.h>
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x27,20,4);
float Trange_Min=20,Trange_Max=30;
float Hrange_Min=40,Hrange_Max=60;
void setup()
{
dht.begin();
lcd.init();
lcd.backlight();
}
void loop()
{
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
float hif = dht.computeHeatIndex(f, h);
float hic = dht.computeHeatIndex(t, h, false);
lcd.setCursor(0,0);
lcd.print("TEMPERATURE:");
lcd.print(t);
lcd.setCursor(0,2);
lcd.print("HUMIDITY:");
lcd.print(h);
if (t<Trange_Min||t>Trange_Max||h<Hrange_Min||h>Hrange_Max){
//
tone(3,700);
}
else {noTone(3);}
if (t<Trange_Min||t>Trange_Max){digitalWrite(4,HIGH);}
else {digitalWrite(4,LOW);}
if (h<Hrange_Min||h>Hrange_Max){digitalWrite(5,HIGH);}
else {digitalWrite(5,LOW);}
}