/* How to use the DHT-22 sensor with Arduino uno
Temperature and humidity sensor
More info: http://www.ardumotive.com/how-to-use-dht-22-sensor-en.html
Dev: Michalis Vasilakis // Date: 1/7/2015 // www.ardumotive.com */
//Libraries
#include <DHT.h>;
//Constants
#define BuzzerPIN 3
#define DHTPIN 2 // 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()
{
Serial.begin(9600);
pinMode(BuzzerPIN, OUTPUT);
dht.begin();
}
void loop()
{
Serial.begin("we start");
float temp = dht.readTemperature();
float hum = dht.readHumidity();
if (isnan(hum)|| isnan(temp)){
Serial.println("Sensor DHT11 is not working");
}
Serial.println(F("Humidity: "));
Serial.print(hum);
Serial.println(F("% Temperature: "));
Serial.print(temp);
if (temp > 25){
tone(BuzzerPIN, 1000);
delay(1000);
noTone(BuzzerPIN);
}
}