#include <DHT.h>
#define DHT_PIN 7
#define DHT_TYPE DHT22
#define sensorMIN 0
#define sensorMAX 512
#define Threshold 300
DHT dht(DHT_PIN,DHT_TYPE);
int value = 0 ; //variable to store the sensor value
int level = 0 ; //variable to store the sensor level
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); //output using serial
dht.begin();
}
void loop() {
// put your main code here, to run repeatedly:
value = analogRead(DHT_PIN);
digitalWrite(DHT_PIN, LOW);
delay(500);
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
if (temperature < 25 && humidity < 25) {
Serial.print("ATTENTION!!! LOW TEMPERATURE");
}
else if (temperature > 35 || humidity >35) {
Serial.print("ATTENTION!!! TEMPERATURE IS HIGH ");
}
else if (temperature > 40 || humidity < 40) {
Serial.print("ATTENTION!!! TEMPERATURE TOO HIGH ");
}
else
level = map(value,sensorMIN,sensorMAX,0,10); // to be 10 levels
Serial.print("TEMPERATURE DETECTED: ");
Serial.print(temperature);
Serial.print(" HUMIDITY: ");
Serial.println(humidity);
}