#include "DHTesp.h"  
//library included of DHT22 for esp32
const int DHT_PIN =13;  
 //input of DHT22 from pin D13 of controller
DHTesp dhtSensor;
int LED_BUILDIN = 2;
//LED INPUT is given from pin D2 
void setup() {
  Serial.begin(9600); 
//serial monitor begin at 9600 baud
  dhtSensor.setup(DHT_PIN, DHTesp::DHT22); 
  // dht22 setup with esp32
  pinMode(LED_BUILTIN, OUTPUT);
//output of LED pin mode is set
  
}
void loop()
 //now loop is started
 {
   float degrees;
//degrees value float
  TempAndHumidity  data = dhtSensor.getTempAndHumidity();
  // temp and humidity data will collect
 // if(TempAndHumidity>50 || TempAndHumidity<5)
  Serial.println("Humidity: " + String(data.humidity, 1) + "%"); 
//read humidity value and print on the serial monitor
  Serial.println("Temp: " + String(data.temperature, 2) + "°C");  
  //read the temperature value and print on serial monitor
  Serial.println("Normal"); 
//print when everything is normal
  delay(1000);  
//delay of 1000
  // LOOP is ended 
  if(degrees>50 || degrees<5) 
//if condition for the temp values 
  {
  digitalWrite(LED_BUILTIN, HIGH);  
//led will go high when the temperature is normal
  delay(1000);    
  // delay of 1000
  }
  else 
{
  digitalWrite(LED_BUILTIN, LOW);    
//LED will go low when temperature will go low or high
  delay(1000); 
//delay of 1000
  }
  }