#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#include <RTClib.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
//variasi font
#include "DSEG7_Classic_Bold_18.h"
#include "DSEG7_Classic_Bold_20.h"
#include "Schoolbell_Regular_18.h"
#define TFT_DC 2
#define TFT_CS 15
#define TFT_RST 4
#define TFT_LED 5
#define TFT_SCK 18
#define TFT_MOSI 23
#define TFT_MISO 19
#define DHTPIN 33
#define DHTTYPE DHT22
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
DHT dht(DHTPIN, DHTTYPE);
RTC_DS1307 rtc;
void setup() {
Serial.begin(115200);
Wire.begin();
rtc.begin();
pinMode(TFT_LED, OUTPUT);
digitalWrite(TFT_LED, HIGH);
tft.begin();
tft.setRotation(4);
tft.fillScreen(ILI9341_BLACK);
dht.begin();
}
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
DateTime now = rtc.now();
String currentDate = String(now.day()) + "-" + String(now.month()) + "-" + String(now.year());
String currentTime = String(now.hour()) + ":" + String(now.minute()) + ":" + String(now.second());
tft.setFont(&DSEG7_Classic_Bold_18);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.setCursor(30, 75); tft.println(String(t) + " *C");
tft.setCursor(30, 150); tft.println(String(h) + " %");
//date & time
tft.setTextColor(ILI9341_RED);
tft.setTextSize(2);
tft.setCursor(30, 230); tft.println(currentTime);
tft.setTextSize(1);
tft.setCursor(50, 275); tft.println(currentDate);
tft.setFont(&Schoolbell_Regular_18);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(1);
tft.setCursor(20, 30); tft.println("Temperature :");
tft.setCursor(20, 100); tft.println("Humidity :");
delay(1000);
}