Introduction: Fire and Temperature Alert

Device Schematic and requirement :

ESP 32 Node Mcu Board - as microcontroller

Fire Sensor Alarm 5 Ways - GPIO pin 4

DHT 11 Temperature and Humidity Sensor - GPIO pin 12/14

Buzzer - GPIO Pin 5

Led - GPIO pin 5

Step 1: How the Device Work

Step 1 : The flame sensor and DHT 11 taking it data and connected to the esp 32

Step 2 : The ESP32 Process the data so it can be shown on the Serial Monitor

Step 3 : The algorithm make a protocol id the sensor reach the certain value it will light up the LED and Ring the buzzer also send the notification on the BLYNK IoT Web Service and mobile

Step 4 : The Buzzer and the LED light up also the notification push to sent

Step 5 : while step 1 - 4 happen, the ESP keep sent the sensor data for shown on the blynk dashboard

Step 2: Example of the Notification and Dashboard

Step 3: The Code

#define BLYNK_TEMPLATE_ID "TMPLba4lREiD"

#define BLYNK_DEVICE_NAME "alert" #define BLYNK_AUTH_TOKEN "CANedxHuwGpci-93gLdVj41u6l0ISnFJ"

#define BLYNK_PRINT Serial #include #if defined(ESP32) #include #elif defined(ESP8266) #include #endif #include

#include #include #include

void sendSensor(); void notification();

char auth[] = BLYNK_AUTH_TOKEN;

char ssid[] = "WIN-I3U26E5IBMR 2736"; // type your wifi name char pass[] = "361Q7{0b"; // type your wifi password

#define DHTPIN 4 // Mention the digital pin where you connected #define DHTTYPE DHT11 // DHT 11 DHT dht(DHTPIN, DHTTYPE); BlynkTimer timer; #define LED 5 #define Buzzer 12 #define Sensor 14

int pinValue = 0;

// void sendSensor(){ // float h = dht.readHumidity(); // float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit // if (isnan(h) || isnan(t)) { // Serial.println("Failed to read from DHT sensor!"); // return; // }

// Serial.println(t); // Blynk.virtualWrite(V6, h); // Blynk.virtualWrite(V5, t); // Serial.print("Temperature : "); // Serial.print(t); // Serial.print(" Humidity : "); // Serial.println(h);

// if(t > 30){ // Blynk.logEvent("temp_alert","Temp above 30 degree"); // } // }

void setup(){ Serial.begin(115200); Blynk.begin(auth, ssid, pass); dht.begin(); timer.setInterval(2500L, sendSensor); pinMode (Sensor,INPUT_PULLUP); pinMode (LED, OUTPUT); }

// void notification(){ // if (Sensor == 1) { // digitalWrite (LED, LOW); // digitalWrite (Buzzer, LOW); // } // else if (Sensor == 0){ // digitalWrite (LED, HIGH); // digitalWrite (Buzzer, HIGH); // } // }

void sendSensor(){ notification(); float h = dht.readHumidity(); float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit if (isnan(h) || isnan(t)) { Serial.println("Failed to read from DHT sensor!"); return; }

Serial.println(t); Blynk.virtualWrite(V6, h); Blynk.virtualWrite(V5, t); Serial.print("Temperature : "); Serial.print(t); Serial.print(" Humidity : "); Serial.println(h);

if(t > 27){ Blynk.logEvent("temp_alert","Temp above 30 degree"); } }

void notification(){

int sensorapi = digitalRead(Sensor);

if (sensorapi == LOW) { digitalWrite (LED, LOW); digitalWrite (Buzzer, LOW); Serial.println ("no fire"); Blynk.logEvent("fire_warning","no fire on the chamber"); } else if (sensorapi == HIGH){ digitalWrite (LED, HIGH); digitalWrite (Buzzer, HIGH); Serial.println ("fire"); } }

void loop(){ Blynk.run(); timer.run(); }