#include <DHT.h>;
//Constants
const int buzzer = 11;
#define DHTPIN 9 // what pin we're connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino
//Variables
int chk;
float hum; //Stores humidity value
float temp; //Stores temperature value
void setup()
{
pinMode(buzzer, OUTPUT);
Serial.begin(9600);
dht.begin();
}
void loop()
{
delay(500);
//Read data and store it to variables hum and temp
hum = dht.readHumidity();
temp= dht.readTemperature();
//Print temp and humidity values to serial monitor
Serial.print("Humidity: ");
Serial.print(hum);
Serial.print(" %, Temp: ");
Serial.print(temp);
Serial.println(" Celsius");
if(hum<=10 || temp>=60){
tone(buzzer, 1000);
}
else{
noTone(buzzer);
}
delay(1000); //Delay 2 sec.
}