#include "DHTesp.h"
#include <LiquidCrystal_I2C.h>
const int DHT_PIN = 15;
int LED_RED = 13;
int LED_GREEN =12;
DHTesp dhtSensor;
LiquidCrystal_I2C LCD = LiquidCrystal_I2C(0x27, 16, 2);
void setup() {
  Serial.begin(115200);
  dhtSensor.setup(DHT_PIN, DHTesp::DHT22);
  pinMode(LED_RED, OUTPUT);
  pinMode(LED_GREEN, OUTPUT);
    LCD.init();
    LCD.backlight(); 
    LCD.setCursor(0, 0);
    LCD.println("ITLPTC");
    LCD.setCursor(0, 1);
    LCD.println("IOT CLASSROOM");
    delay(2000);
}

void loop() {
  TempAndHumidity  data = dhtSensor.getTempAndHumidity();
  LCD.clear();
  LCD.setCursor(0, 0);
  LCD.print("NAKARIN");
  LCD.setCursor(0, 1);
  LCD.print("JUILOMGMUEANG ");
  delay(2000);

  if(data.temperature >= 35.0)
  {
    LCD.clear();
    LCD.setCursor(0, 0);
    digitalWrite(LED_RED, HIGH);
    digitalWrite(LED_GREEN, LOW);
    LCD.println("Wearther Hot");
    
    
    
  }
  else{
    LCD.clear();
    LCD.setCursor(0, 0);
    digitalWrite(LED_RED, LOW);
    digitalWrite(LED_GREEN, HIGH);
    LCD.print("Wearther Cool");
    
  }
  LCD.setCursor(0, 1);
  LCD.println("Temp: " + String(data.temperature, 2) + "oC");
   delay(2000);
  LCD.setCursor(0, 1);
  LCD.println("Humidity: " + String(data.humidity, 1) + "%");
  LCD.println("---");
  delay(3000);
}