#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include "DHT.h"
#define DHTPIN 33
#define DHTTYPE DHT22
#define BUZZER 4
DHT dht(DHTPIN, DHTTYPE);
#define TFT_DC 2
#define TFT_CS 15
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
float temp_value;
const int RED = 0;
const int GREEN = 16;
void setup() {
// put your setup code here, to run once:
tft.begin();
tft.setRotation(0);
tft.fillScreen(ILI9341_BLACK);
tft.setCursor(15, 150);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.println("FIRE ALARM DETECTION");
pinMode(BUZZER, OUTPUT);
Serial.begin(115200);
pinMode(RED, OUTPUT);
pinMode(GREEN, OUTPUT);
dht.begin();
}
void loop() {
// put your main code here, to run repeatedly:
//analogRead(A5);
float h = dht.readHumidity();
float t = dht.readTemperature();
//float f = dht.readTemperature(true);
Serial.print("Humidity: ");
Serial.println(h);
Serial.print("Temperature: (°C) ");
Serial.println(t);
if( h >= 80 || t>= 70 )
{
digitalWrite(BUZZER,HIGH);
digitalWrite(RED,HIGH);
//delay(500);
digitalWrite(GREEN,LOW);
}
else{
digitalWrite(RED,LOW);
digitalWrite(GREEN, HIGH);
digitalWrite(BUZZER, LOW);
}
}