#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include "DHT.h"
#include <Wire.h>
#define TFT_SCK 18
#define TFT_MOSI 23
#define TFT_MISO 19
#define TFT_CS 22
#define TFT_DC 21
#define TFT_RESET 17
#define DHTPIN1 25
#define DHTPIN2 26
#define DHTPIN3 27
#define DHTPIN4 14
#define DHTTYPE DHT22
DHT dht1(DHTPIN1, DHTTYPE);
DHT dht2(DHTPIN2, DHTTYPE);
DHT dht3(DHTPIN3, DHTTYPE);
DHT dht4(DHTPIN4, DHTTYPE);
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
const int r =4;
const int g = 0;
const int b= 2;
void setup() {
Serial.begin(115200);
pinMode(r,OUTPUT);
pinMode(g,OUTPUT);
pinMode(b,OUTPUT);
Serial.println(F("DHTxx test!"));
dht1.begin();
dht2.begin();
dht3.begin();
dht4.begin();
tft.begin();
}
void loop() {
float t1 = dht1.readTemperature();
float f1 = dht1.readTemperature(true);
float t2 = dht2.readTemperature();
float f2 = dht2.readTemperature(true);
float t3 = dht3.readTemperature();
float f3 = dht3.readTemperature(true);
float t4 = dht4.readTemperature();
float f4 = dht4.readTemperature(true);
tft.setRotation(1);
tft.fillScreen(0xFFFF);
tft.setCursor(18, 10);
tft.setTextColor(ILI9341_BLACK);
tft.setTextSize(2);
tft.println("Sri Sairam Eng. Clg");
tft.setCursor(45, 42);
tft.setTextColor(ILI9341_BLUE);
tft.setTextSize(2);
tft.println("Tempature Sensor");
if(t1>=40 || t2>=40 || t3>=40 || t4>=40)
{
tft.setCursor(24, 82);
tft.setTextColor(ILI9341_RED);
tft.print(t1);
tft.print(" ");
tft.print(char(223));
tft.print("C");
tft.setCursor(184, 82);
tft.setTextColor(ILI9341_RED);
tft.print(t2);
tft.print(" ");
tft.print(char(223));
tft.print("c");
tft.setCursor(24, 122);
tft.setTextColor(ILI9341_RED);
tft.print(t3);
tft.print(" ");
tft.print(char(223));
tft.print("C");
tft.setCursor(184, 122);
tft.setTextColor(ILI9341_RED);
tft.print(t4);
tft.print(" ");
tft.print(char(223));
tft.print("c");
tone(16, 25, 200);
digitalWrite(r, HIGH);
digitalWrite(g, LOW);
digitalWrite(b, LOW);
}
else
{
tft.setCursor(24, 82);
tft.setTextColor(ILI9341_GREEN);
tft.print(t1);
tft.print(" ");
tft.print(char(223));
tft.print("C");
tft.setCursor(184, 82);
tft.setTextColor(ILI9341_GREEN);
tft.print(t2);
tft.print(" ");
tft.print(char(223));
tft.print("F");
tft.setCursor(24, 122);
tft.setTextColor(ILI9341_GREEN);
tft.print(t3);
tft.print(" ");
tft.print(char(223));
tft.print("C");
tft.setCursor(184, 122);
tft.setTextColor(ILI9341_GREEN);
tft.print(t4);
tft.print(" ");
tft.print(char(223));
tft.print("c");
digitalWrite(r, LOW);
digitalWrite(g, HIGH);
digitalWrite(b, LOW);
}
delay(1000);
}