#include <LiquidCrystal_I2C.h>
#include <DHTesp.h>
#define ldr 34
#define led 4
const int DHT_PIN = 15;

DHTesp dhtSensor;
LiquidCrystal_I2C mylcd(0x27,16,2);


int x,i=0;
void setup(){
  Serial.begin(115200);
  pinMode(ldr, INPUT);
  pinMode(led, OUTPUT);
  digitalWrite(led,LOW);
  dhtSensor.setup(DHT_PIN,DHTesp::DHT22);
  mylcd.init();
  mylcd.backlight(); 
  
 }
void loop(){
  TempAndHumidity data= dhtSensor.getTempAndHumidity();
  x = analogRead(ldr);
  Serial.println(x);
  Serial.println("Temp ="+String(data.temperature,2)+ "ํ ํC");
  Serial.println("Humidity ="+String(data.humidity,1)+ "ํ %");
  Serial.println("-----------");
  delay(1000);
  if(i != x){
    mylcd.clear();
    mylcd.setCursor(0,0); mylcd.print("Value =");
    mylcd.setCursor(7,0); mylcd.print(x);
    mylcd.setCursor(0,1); mylcd.print("Temp =");
    mylcd.setCursor(6,1); mylcd.print(data.temperature);mylcd.print("C");
    if(x <=2000){
      digitalWrite(led, HIGH);
    }else{
      digitalWrite(led, LOW);
    }
    delay(500);
  }i = x = data.temperature;
  
 }