IoT Based Fire Alarm System DIY - ESP32

 This Mini project was constructed by:

  1. MUHAMMAD TORIQ ZIYAD BIN SAIFUL              212010977
  2. MUHAMMAD IRFAN BIN RUSLI                           212010966
  3. MUHAMMAD ZULFIKRY ZAKY BIN ZUBIR            212010983
  4. MUHAMMAD IZHAR BIN ABD MALEK                  212010967
  5. MUHAMMAD THAQIF AMMAR BIN ZULFIKRI        212010976

1.0 Introduction


DIY IoT Based Fire Alarm System - ESP32


   In an era where technology continually reshapes our safety measures, the Internet of Things (IoT) emerges as a game-changer, revolutionizing how we approach safety and security. Today, we're excited to explore one of its practical applications: an IoT-based fire alarm system using the versatile ESP32 microcontroller. This project not only highlights IoT's power in enhancing safety but also showcases the ESP32's potential in creating efficient, responsive, and connected safety solutions. We'll also delve into how this system can send crucial notifications through platforms like Telegram, demonstrating the real-time benefits of IoT in keeping us safe and informed.

  Below provided with closer look at the hardware, software, and step-by-step instructions required to build this innovative fire alarm system. It's a crucial step forward in smart safety technology, providing real-time alerts and greater peace of mind in emergency situations.

2.0 Objectives


  • Early Fire Detection: Create an IoT-based fire alarm system for early fire and smoke detection using sensors.
  • Immediate Alerting: Enable real-time fire emergency notifications through Telegram for quick user alerts.
  • Remote Monitoring: Provide users with remote system status monitoring for enhanced accessibility and usability.

3.0 Problem Statement


   In today's rapidly evolving technological landscape, ensuring the safety and security of individuals and properties is of paramount importance. Fires can pose a significant threat to both life and assets, and early detection is crucial in minimizing damage and saving lives. Traditional fire alarm systems, while effective to some extent, often lack the capability for real-time monitoring and immediate alerting. Moreover, they may not provide users with the convenience of remote access and control.

This project aims to address these limitations by developing an IoT-based fire alarm system that leverages the power of the Internet of Things (IoT) and the versatility of the ESP32 microcontroller. The primary problem we seek to solve is the need for a more efficient and responsive fire detection and alerting system that can provide early warning and instant notifications to users, ensuring their safety and peace of mind.

4.0 Literature Review


4.1 IoT-Based Fire Detection using ESP32 and Flame Sensor with Email Alert

   This project involves creating an IoT-based fire detection system using an Infrared flame sensor and ESP32, with an email alert feature via the IFTTT web service. The system notifies users of fire detection, providing date and time details. Additionally, it configures an ESP32 digital pin to connect an LED, indicating fire detection. The Infrared flame sensor detects flames in the 760nm to 1100nm wavelength range, featuring adjustable sensitivity and a 60-degree detection point. Outputs include analog voltage and digital signals with a threshold setting. The project aims to enhance safety through fire detection, applicable in various scenarios.

4.2 IoT-Based Fire Safety System Using MQTT Communication Protocol

   This mini project introduces an IoT-based fire safety system consisting of a detector, processing unit, and surveillance component. The detector integrates ESP32, carbon monoxide and ionization smoke sensors, a buzzer, and temperature/humidity sensors. The Raspberry Pi-driven Node-RED application processes data through the MQTT protocol for efficient communication between the detector and processing unit. A surveillance unit with a camera continuously monitors the surroundings. In case of a confirmed fire breakout, the system triggers an alarm and sends GPS coordinates along with a floor plan to the nearby fire station, showcasing effective fire detection and response capabilities. Experimental results affirm the system's promising performance.

4.3 IoT based Fire Security Alarm System using NodeMCU | Custom Android App

   This project details the creation of an IoT-based Fire Security Alarm System using NodeMCU and a custom Android app, incorporating various sensors for comprehensive fire and smoke detection. The system, centered around the ESP8266 NodeMCU, features a Flame Sensor and MQ2 Smoke Sensor, offering the ability to detect a range of gases. Additionally, a 5V Buzzer and LED serve as audio and visual indicators for alerts. The project's materials include a Transistor BC547, resistors, jumper cables, and a breadboard. The use of a MQ2 gas sensor module enhances the sensor interface, ensuring an effective and versatile approach to fire security.

5.0 Methodology


Block Diagram - Methodology

   In this project, we will construct a DIY of IoT Based Fire Alarm System, employing an Infrared flame sensor coupled with an ESP32, which includes a message alert functionality. This project integrates with the Telegram app, enabling it to send message alerts to users in the event of fire detection. Users will receive timely updates, complete with the precise date and time when fire or flames are detected. Furthermore, we plan to set up a digital pin on the ESP32 board as an output, connecting it to an LED, a buzzer, and an LCD. Upon detection of fire, the LED and buzzer will activate, while the LCD will display a predefined message.

Project's Flow Chart:

   The fire detection system described in this document is a comprehensive and efficient solution for ensuring fire safety and emergency response. It seamlessly combines hardware components, such as the IR Flame Sensor, LCD display, LED, and buzzer, with software elements like the Telegram Bot to create a robust fire detection and notification system.

The system's initialization begins with establishing a connection to a Telegram Bot, enabling it to send alerts and notifications to designated recipients or groups on the Telegram platform. This foundational step sets the stage for the entire system's operation.

Once the system is up and running, it communicates its status through various means. It sends a "Bot Started Up" notification to confirm its operational readiness and displays "Flare Guard" on an LCD screen to visually indicate its readiness to detect fires.

The core functionality of the system lies in its ability to detect fires using an IR Flame Sensor. This specialized sensor can detect changes in infrared radiation caused by flames, triggering the system to check for the presence of a fire. If a fire is detected, the system responds with a series of actions, including visual and auditory alerts, as well as sending a "FIRE!!! FIRE!!! FIRE!!!" notification via Telegram to inform relevant parties.

In the post-fire detection phase, responders are prompted to take immediate action, including evacuating people, contacting emergency services, and monitoring the situation. The system may continue to provide updates to ensure effective coordination and control of the fire. After the situation is under control, the system can be reset to its default state, ready for the next monitoring cycle.

The integration of a Telegram Bot into the system is a critical component, allowing real-time notifications to be delivered to users or groups on the Telegram platform. Setting up the Telegram Bot involves creating it through the Telegram BotFather, obtaining a unique Bot Token, and configuring the system to use this token for message delivery. The benefits of this integration include fast and reliable notifications, versatile accessibility across various devices, and the ability for remote monitoring of fire emergencies.

5.1 Hardware Development


List of Components Used:
  1. ESP32 development board
  2. IR Flame Detection Sensor
  3. LCD Display Screen 16x2 L2C
  4. LED - Basic Red 5mm
  5. Piezo Buzzer
  6. Transistor - NPN BC337
  7. Resistor - 1k ohm and 100 ohm

Put together the devices following the schematic diagram provided below:


IoT Fire Alarm System's Schematic Diagram



Hardware Setup Configuration:

  1. Three pins from the IR Flame Detection Sensor module will be linked to the ESP32: VCC, GND, and DO. The VCC pin will attach to the ESP32's Vin pin. A common ground will be established for both devices. The ESP32's digital pin will be connected to the DO pin.
  2. For the LED, the ESP32's digital pin is connected to the LED's anode, while the cathode is linked to the common ground via a 100-ohm resistor.
  3. Regarding the LCD, the ESP32's digital pins are connected to the LCD's SDA and SDL pins. The LCD's GND and VCC are also connected to the breadboard's GND and VCC bus.
  4. Finally, for the buzzer, its anode pin is connected to the breadboard's bus line, and its cathode pin to the transistor's collector pin. The transistor's base pin is connected to a digital pin on the ESP32 through a 1k ohm resistor, and its emitter pin is linked to the ground.



IoT Fire Alarm System's Hardware Setup


   To further enhance our IoT fire alarm system, we placed all the properly installed components into a decorated box and named it the "Flare Guard Box."


Flare Guard Box


5.2 Software Development


Below is The Coding of Fire Alarm System with a bit of explanation next to each instruction:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <UniversalTelegramBot.h>
#include <ArduinoJson.h>

const char* ssid = "WIFISDNBHD"; // Set WiFi SSID
const char* password = "badrull"; // Set WiFi password

#define BOTtoken "6315719383:AAFdCv5rMwpVeVdbUioNUmkLhi1sOzJXRwQ" // Connect with Telegram Bot
#define CHAT_ID "929727877" // Put Telegram chat ID

WiFiClientSecure client; // Create a secure WiFi client
UniversalTelegramBot bot(BOTtoken, client); // Create a Telegram bot instance

LiquidCrystal_I2C lcd(0x27, 16, 2); // Set up the LCD with I2C address and size

const int flameSensorPin = 4; // Define the pin for the IR flame sensor
const int buzzerPin = 5;      // Define the pin for the buzzer
const int ledPin = 13;        // Built-in LED on the ESP32

void setup() {
  Serial.begin(115200); // Initialize serial communication
  pinMode(flameSensorPin, INPUT);
  pinMode(buzzerPin, OUTPUT);
  pinMode(ledPin, OUTPUT);

  Serial.print("Connecting Wifi: ");
  Serial.println(ssid);

  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password); // Connect to WiFi
  client.setCACert(TELEGRAM_CERTIFICATE_ROOT);

  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
    
    lcd.init();
    lcd.backlight();
    lcd.setCursor(0, 0);
    lcd.print("  Flare Guard!");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  bot.sendMessage(CHAT_ID, "Bot started up", ""); // Send a Telegram message on startup
}

void loop() {
  int flameDetected = digitalRead(flameSensorPin);

  if (flameDetected == HIGH) {
    lcd.setCursor(0, 1);
    lcd.print("Safe Condition:)");
    digitalWrite(ledPin, LOW);
    noTone(buzzerPin);
  }
   else 
  {
    lcd.setCursor(0, 1);
    lcd.print("Flame Detected!!!");
    digitalWrite(ledPin, HIGH);
    tone(buzzerPin, 1000);
    bot.sendMessage(CHAT_ID, "FIRE!!! FIRE!!! FIRE!!!", ""); // Send a Telegram message on flame detection
    Serial.println("FIRE!!! FIRE!!! FIRE!!!"); 
  }
  delay(1000); // Delay for stability
}

Summary of The Code:

   This Arduino code sets up an ESP32-based system with a flame sensor, buzzer, LED, and LCD display. It connects to a Wi-Fi network and sends a Telegram message when the flame sensor detects a flame. The LCD displays the system status, and the buzzer and LED provide alerts. The code structure includes setup and loop functions for initialization and continuous operation.


6.0 Result and Discussion




   In the absence of a detected fire by the IR flame sensor, the system adopts a tranquil stance. The LED remains dormant, refraining from emitting visual alerts, while the buzzer stays silent, maintaining a quiet auditory environment. Simultaneously, the LCD displays the reassuring message "Safe Condition :)" to visually confirm the absence of potential fire threats. Importantly, no notifications are sent through Telegram during these non-fire scenarios, ensuring a focused communication strategy and minimizing unnecessary disruptions for users.




   When the IR flame sensor identifies a fire, the system promptly responds with a visual cue: the LED activates, and an audible alarm is triggered through the buzzer, accompanied by the LCD displaying the message "Flame Detected ! !". Simultaneously, the system initiates a continuous stream of Telegram notifications, sending updates every second as long as the fire condition persists. This proactive notification strategy ensures timely communication with users, keeping them informed about the ongoing fire situation throughout its duration.



   Upon detecting a fire, the system sends Telegram notifications with the urgent message "FIRE!!! FIRE!!! FIRE!!!". This succinct alert conveys the critical nature of the situation, prompting immediate attention and action from users.


   Upon detecting a fire, the system sends Telegram notifications every second, ensuring continuous real-time updates for as long as the fire persists. This rapid and recurring notification strategy aims to promptly and consistently inform users about the evolving fire situation.


7.0 Video Demonstration

  
 Below is our Mini Project's Video Presentation:




8.0 Conclusion 


  In conclusion, this mini project has effectively developed a DIY IoT-based fire alarm system with a primary objective of early fire detection, along with the added capabilities of alerting and remote monitoring. The system utilizes appropriate sensors to detect potential fire hazards in their early stages, enabling swift response measures. Additionally, it offers the convenience of remote monitoring, ensuring users can stay informed about their environment's safety and take necessary actions promptly. This achievement represents a significant step in enhancing fire safety and emergency response in a variety of settings.

   Moreover, the incorporation of fire detectors into Telegram applications is a positive move in the direction of improving fire safety protocols. An alarm is set off when a fire detector, like an infrared sensor, detects possible fire threats. People inside the building are immediately notified of this alarm, which is smoothly delivered to any connected Telegram applications. The utilization of Telegram results in real-time alerts for building residents, irrespective of their location. This facilitates prompt responses and evacuations, thus augmenting the building's overall safety protocols. This integration demonstrates the ability of IoT technology to provide prompt communication and preventative actions to save lives and property in the event of a fire.


9.0 Future Work

Mobile Application Development:
Developing a dedicated mobile application to complement the existing Android app could enhance user experience and accessibility. A user-friendly interface with additional features, such as historical data visualization, personalized settings, and real-time system status updates, would contribute to a more comprehensive and user-centric fire safety solution.

Machine Learning Integration:
The inclusion of machine learning algorithms presents an exciting avenue for refining the system's ability to distinguish between false alarms and actual fire incidents. By leveraging machine learning models, the system could adapt and learn from different environmental conditions, minimizing false positives and optimizing response mechanisms. This approach could significantly improve the system's efficiency and reliability over time.

Enhanced Sensor Integration:
In future iterations of the IoT-based fire alarm system, there is potential for incorporating more advanced sensors with increased accuracy and sensitivity. Exploring cutting-edge sensor technologies could further improve the system's ability to detect fire hazards in diverse environments. For instance, integrating multispectral sensors capable of detecting specific types of smoke or gases can enhance the system's overall reliability.

By addressing these potential areas of improvement and exploration, the future iterations of the IoT-based fire alarm system can evolve into a more sophisticated and adaptive solution, contributing to enhanced fire safety practices and emergency response strategies.


Comments