#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include "Humidity.h"

#define TFT_DC 4
#define TFT_CS 2
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
// -----------  DHT22 --------------
#include "DHT.h"
#define DHTPIN 33     // Digital pin connected to the DHT sensor
#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);
  Serial.println("DHT22 Temp Controll");
  dht.begin();

  tft.begin();
  tft.setRotation(1);
  tft.fillScreen(ILI9341_BLACK);
  tft.setCursor(3, 0);
  tft.setTextColor(ILI9341_YELLOW);
  tft.setTextSize(3);
  tft.println("TEMP,HUM CONTROL");

  tft.setCursor(30, 80);
  tft.setTextColor(ILI9341_PINK);
  tft.setTextSize(2);
  tft.println("TEMP : ");
  tft.setCursor(30, 120);
   tft.println("HUMID: ");
}

void loop() {
  tft.drawRGBBitmap(0 , 0,(uint16_t *)dragonBitmap,DRAGON_WIDTH, DRAGON_HEIGHT);
    delay(300);

   float h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();
    tft.setCursor(125, 180);
  tft.setTextColor(ILI9341_PINK);
  tft.setTextSize(3);
  tft.println(String(h) + " %");
  // --------- Showe On Serial Monitor  --------
  Serial.print("Temp: "+(String(t)+" C"));
  Serial.println("  Humid: "+(String(h)+" % "));
  delay(1000);

  // ----------- Display On TFT  ----------
  if(t<26){
  tft.setCursor(125, 85);
  tft.setTextColor(ILI9341_GREEN,ILI9341_WHITE);
  tft.setTextSize(3);
  tft.println(String(t)+ " C");
  }
    if(t>=26 &&t<=29){
  tft.setCursor(125, 85);
  tft.setTextColor(ILI9341_BLUE,ILI9341_WHITE);
  tft.setTextSize(3);
  tft.println(String(t)+ " C");
  }
      if(t>=30){
  tft.setCursor(125, 85);
  tft.setTextColor(ILI9341_RED,ILI9341_WHITE);
  tft.setTextSize(3);
  tft.println(String(t)+ " C");
  }

}
NOCOMNCVCCGNDINLED1PWRRelay Module
NOCOMNCVCCGNDINLED1PWRRelay Module