#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <SPI.h>
#include <DHT.h>
#define TFT_DC 2
#define TFT_CS 15
#define TFT_RST 4
#define POTMAX 32
#define POTMIN 35
#define POTMINUTS 25
#define POTHOURS 34
#define BUTTONY 16
#define BUTTONN 17
#define DHTPIN 3
#define DHT_SENSOR_TYPE DHT22
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
DHT dht_sensor(DHTPIN, DHT_SENSOR_TYPE);
int hours;
int minuts;
int minT;
int maxT;
float tempC;
void setup() {
tft.begin();
tft.setRotation(1);
tft.setTextSize(3);
tft.setCursor(0, 0);
tft.setTextColor(ILI9341_CYAN, ILI9341_BLACK);
Serial.begin(115200);
tft.print("welcome");
delay(500);
}
void loop() {
while (digitalRead(BUTTONY) == LOW)
{
tft.setCursor(0, 0);
tft.println("Set the time, max and min temp: ");
tft.print("Hours: ");
hours = map(analogRead(POTHOURS), 0, 4098, 0, 23);
tft.println(hours);
tft.print("Minutes: ");
minuts = map(analogRead(POTMINUTS), 0, 4098, 0, 59);
tft.println(minuts);
tft.print("Max temperature: ");
maxT = map(analogRead(POTMAX), 0, 4098, 0, 80);
tft.println(maxT);
tft.print("Min temperature: ");
minT = map(analogRead(POTMIN), 0, 4098, 0, 80);
tft.println(minT);
delay(50);
}
tft.fillScreen(ILI9341_BLACK);
tft.setCursor(0, 0);
tft.print("All is set");
delay(500);
tempC = dht_sensor.readTemperature();
while (isnan(tempC)) {
Serial.println("Failed to read DHT22");
tempC = dht_sensor.readTemperature();
delay(50);
}
while (digitalRead(BUTTONN) == LOW)
{
tft.setCursor(0, 0);
tft.println("Boiler is in set");
tft.print("Current temp is: ");
tft.print(tempC);
delay(50);
}
}