0% found this document useful (0 votes)
68 views61 pages

B.Tech. BCSE497J - Project-I: Iot-Based Smart Smoke Detection System With Real-Time Alert Messages

Uploaded by

parigawali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views61 pages

B.Tech. BCSE497J - Project-I: Iot-Based Smart Smoke Detection System With Real-Time Alert Messages

Uploaded by

parigawali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

B.Tech.

BCSE497J - Project-I

IOT-BASED SMART SMOKE DETECTION SYSTEM WITH


REAL-TIME ALERT MESSAGES

Submitted in partial fulfilment of the requirements for the degree of

B.Tech.
in
Computer Science and Engineering

21BCT0290 SHIVEN GUPTA


21BCE3687 DHRUV SHAH
21BDS0311 ANKUR ROHILLA

Under the Supervision of

DR. BERLIN M A
Associate Professor Grade 2
School of Computer Science and Engineering
(SCOPE)

November 2024
ii
ii
ACKNOWLEDGEMENTS

I am deeply grateful to the management of Vellore Institute of Technology (VIT) for


providing me with the opportunity and resources to undertake this project. Their commitment
to fostering a conducive learning environment has been instrumental in my academic journey.
The support and infrastructure provided by VIT have enabled me to explore and develop my
ideas to their fullest potential.

My sincere thanks to Dr. Ramesh Babu K, the Dean of the School of Computer Science
and Engineering (SCOPE), for his unwavering support and encouragement. His leadership and
vision have greatly inspired me to strive for excellence. The Dean’s dedication to academic
excellence and innovation has been a constant source of motivation for me. I appreciate his
efforts in creating an environment that nurtures creativity and critical thinking.

I express my profound appreciation to Dr. Umadevi K S, the Head of the Computer Science
and Engineering, for her insightful guidance and continuous support. Her expertise and advice
have been crucial in shaping the direction of my project. The Head of Department’s
commitment to fostering a collaborative and supportive atmosphere has greatly enhanced my
learning experience. Her constructive feedback and encouragement have been invaluable in
overcoming challenges and achieving my project goals.

I am immensely thankful to my project supervisor Dr. Berlin M A, for her dedicated


mentorship and invaluable feedback. Her patience, knowledge, and encouragement have been
pivotal in the successful completion of this project. My supervisor’s willingness to share her
expertise and provide thoughtful guidance has been instrumental in refining my ideas and
methodologies. Her support has not only contributed to the success of this project but has also
enriched my overall academic experience.

Thank you all for your contributions and support.

Ankur rohilla

iii
TABLE OF CONTENTS

Sl.No Contents Page No.


Declaration i
Certificate ii
Acknowledgements iii
Abstract vii
1. INTRODUCTION 1
1.1 Background 1
1.2 Motivations 2
1.3 Scope of the Project 3
2. PROJECT DESCRIPTION AND GOALS 5
2.1 Literature Review 5
2.2 Research Gap 8
2.3 Objectives 10
2.4 Problem Statement 11
2.5 Project Plan 12
3. TECHNICAL SPECIFICATIONS 14
3.1 Requirements 14
3.1.1 Functional 14
3.1.2 Non-Functional 16
3.2 Feasibility Study 17
3.2.1 Technical Feasibility 17
3.2.2 Economic Feasibility 18
3.2.3 Social Feasibility 19
3.3 System Specification 20
3.3.1 Hardware Specification 20
3.3.2 Software Specification 20
4. DESIGN APPROACH AND DETAILS 21
4.1 System Architecture 21
4.2 Design 25
4.2.1 Data Flow Diagram 25
4.2.2 Use Case Diagram 26
4.2.3 Class Diagram 27
iv
4.2.4 Sequence Diagram 28
5. METHDOLOGY AND TESTING 29
6. PROJECT DEMONSTRATION 35
7. RESULT AND DISCUSSION 41
8. CONCLUSION 44
9. REFERENCES 47
Appendix A-SAMPLE CODE 49

v
List Of Figures

Figure no. Title Page No.


1 Hardware Component 35
2 Cloud Platform 37
3 Blynk Mail 39
4 Arduino Code 41

vi
ABSTRACT

In this project, we explore the development and implementation of a Smart Smoke Detection
System that leverages the Internet of Things (IoT) to significantly improve fire safety and
security. This innovative system incorporates advanced sensors capable of detecting not only
smoke but also toxic gases such as carbon monoxide, methane, and other harmful substances
that may be indicative of a fire. These sensors provide real-time data to the central processing
unit, enabling the system to assess and analyze potential fire risks effectively.
The heart of the system is its cloud-based platform, which acts as a processing and
communication hub. As soon as any of the sensors detect smoke, gas, or flame, the platform
processes the data and triggers immediate action. The system sends alerts to designated
recipients through various communication channels, including SMS, email, and mobile app
notifications. This ensures that individuals are notified about the hazard regardless of their
location, providing an immediate warning even if they are not present in the building or on-
site. Additionally, emergency services can be notified automatically, facilitating a quicker
response time and reducing the potential for property damage or loss of life.
One of the key features of this system is its ability to minimize false alarms through the
integration of adaptive learning algorithms. These algorithms enable the system to distinguish
between actual fire threats and non-threatening incidents that might trigger false alarms, such
as cooking smoke or dust. By continuously learning from environmental data and sensor
feedback, the system becomes more efficient and accurate over time, reducing the chances of
users becoming desensitized to the alerts or ignoring the system altogether.
Furthermore, the Smart Smoke Detection System is designed to be integrated with other smart
home appliances, contributing to an overall smart safety ecosystem. For example, when a fire
hazard is detected, the system can automatically take preventive actions such as shutting off
the electrical circuits to prevent further fire escalation or activating the sprinkler system to
suppress the fire. This level of automation not only enhances safety but also provides peace of
mind for users, knowing that the system will take necessary actions even in their absence.
The system is adaptable and scalable, making it suitable for a wide range of applications, from
small residential homes to large commercial buildings and industrial environments. It is
designed to be easily customizable, allowing users to tailor the system to their specific needs
and preferences. This flexibility ensures that the system can be deployed in a variety of settings
and can grow with the needs of the user.
By combining state-of-the-art sensor technology, cloud computing, and IoT connectivity, this
Smart Smoke Detection System offers a comprehensive solution for fire safety. It not only
provides real-time hazard detection and alerting but also integrates with smart home devices to
enhance safety further through automation. This system represents a significant step forward
in creating safer living and working environments by harnessing the power of technology to
protect individuals, businesses, and industries from the devastating impacts of fire hazards.
The system's integration with IoT platforms such as Blynk allows users to monitor the status
of their smoke detection system remotely, giving them control and access to real-time updates
via mobile apps. Additionally, the low-cost hardware and simple setup make it an accessible
option for users across different sectors, contributing to widespread adoption. As we move

vii
towards an increasingly connected and technology-driven world, this system offers a scalable,
efficient, and intelligent solution to improving fire safety, ultimately contributing to a safer and
smarter society.

viii
1. INTRODUCTION

1.1 BACKGROUND

Conventional smoke detection systems primarily rely on either ionization or photoelectric


detection methods to identify smoke particles and potential fire hazards. In ionization smoke
detectors, a small radioactive source ionizes the air in a sensing chamber, creating a flow of
electric current. When smoke enters the chamber, it disrupts the ionization process, which then
triggers an alarm. These detectors are particularly effective at identifying fast-burning, flaming
fires. Photoelectric smoke detectors, on the other hand, contain a light source and a light-
sensitive element within a chamber. Smoke particles scatter the light beam, causing it to reflect
onto the light sensor, which in turn triggers the alarm. This type of detector is more responsive
to smoldering, smoky fires.

While ionization and photoelectric detectors provide essential smoke detection, they come with
notable limitations. Local-only alarms—which make up over 90% of conventional smoke
detectors—simply emit a sound locally when smoke is detected but do not communicate with
other systems or alert external help such as emergency services. This limitation means that,
unless someone is close enough to hear the alarm and respond, the alert may go unnoticed,
reducing its effectiveness in situations where immediate action is required.

Additionally, false positives are a common issue in conventional detectors. Everyday non-
threatening activities, such as cooking or steam from showers, can easily set off the alarm. This
issue often results in alarm fatigue, where frequent false alarms cause people to ignore the
alerts, potentially overlooking a genuine emergency. In such cases, conventional alarms lose
their reliability and efficacy, as users may disregard alarms after multiple false triggers, leaving
them less protected in real fire situations.

Another significant drawback of traditional smoke detectors is their lack of real-time


notification and limited integration with modern smart home systems. They are not equipped
to send real-time alerts to users who may not be present at the location, nor can they interact
with smart home devices for enhanced safety measures, such as automatically turning off
electrical appliances, activating sprinklers, or notifying emergency contacts or services. In
contrast, smart smoke detection systems offer these advanced features, providing users with
instant alerts through mobile apps or SMS, integration with IoT devices for enhanced response
actions, and the ability to distinguish between genuine and non-threatening smoke events to
reduce false alarms.

In summary, while ionization and photoelectric smoke detectors have served as essential tools
in fire safety, their local-only alert limitations, susceptibility to false alarms, and lack of
connectivity reveal significant disadvantages in the context of today’s safety needs. Smart

1
smoke detection systems address these gaps by offering real-time alerts, advanced sensor
technology to minimize false positives, and compatibility with smart home systems, ultimately
enhancing safety and providing users with a more reliable and responsive fire detection
solution.

1.2 MOTIVATIONS
This paper emphasizes the necessity of developing an IoT-based Smart Smoke Detection
System to address the significant limitations present in traditional smoke detectors.
Conventional smoke detection systems, which often rely on either ionization or photoelectric
technology, are typically limited to local-only alerts. Once triggered, these systems only sound
an alarm within their immediate vicinity and cannot communicate or interact with broader
networks, meaning the alert may not reach all individuals within the affected area. This
limitation can critically delay the response time during emergencies, especially when people
are spread across a large building or in remote parts of a facility.
The advent of Internet of Things (IoT) technology introduces opportunities for innovative
smoke detection solutions that provide real-time monitoring, alerts, and connectivity. An IoT-
based smoke detection system can monitor conditions continuously and alert users immediately
upon detecting potential fire hazards, regardless of the user’s location. Unlike traditional
alarms, which are only effective within audible range, IoT-based systems can send notifications
to users through multiple channels—including SMS, email, and mobile applications. This
capability ensures that users are informed of potential risks instantly, whether they are on-site
or far away, providing a significant enhancement in safety and situational awareness.

Furthermore, IoT-based systems can incorporate adaptive learning algorithms to enhance


reliability and minimize false alarms. These algorithms enable the system to differentiate
between real fire hazards and non-threatening activities, such as cooking or steam from a
shower, that may produce smoke or heat without signaling danger. By distinguishing real
threats from harmless situations, the system can reduce alarm fatigue caused by frequent false
positives, ensuring that users only receive alerts for genuine emergencies.
Beyond enhanced detection and alerting capabilities, an IoT-enabled smoke detection system
can interact with other smart devices within a building. This connectivity enables the system
to perform automated safety actions in response to detected hazards, such as automatically
switching off electrical circuits to reduce fire risks or activating sprinkler systems to contain a
potential fire. These automated responses provide a proactive approach to fire safety,
minimizing the need for immediate human intervention and helping to mitigate the situation
even before emergency responders arrive.
In conclusion, an IoT-based smart smoke detection system represents a significant
advancement over conventional smoke detectors, offering real-time, remote alerts, adaptive

2
learning for false alarm reduction, and interoperability with other smart home or building
devices. Such a system not only enhances the reliability and responsiveness of smoke detection
but also supports automated safety measures, thus promoting a safer environment through rapid
detection, notification, and preventive actions. This paper argues that the integration of IoT
technology in smoke detection is essential to address the limitations of traditional systems and
to improve overall safety and emergency preparedness.

1.3 SCOPE OF THE PROJECT


This paper presents the IoT-based Smart Smoke Detection System, a solution designed to
overcome the limitations of conventional smoke detectors through enhanced technology and
connectivity. Traditional smoke detectors primarily focus on detecting smoke particles and
often lack the ability to differentiate between benign sources (like cooking smoke) and actual
fire threats, leading to frequent false alarms and alarm fatigue. In contrast, the IoT-based system
proposed here incorporates specific sensors capable of detecting not only smoke but also toxic
gases, such as carbon monoxide, providing a more comprehensive approach to fire detection
and safety. By identifying a broader range of hazardous elements, the system offers heightened
security in various environments.

The integration of an IoT device enables the system to connect to a cloud-based platform, which
allows for continuous monitoring, processing, and real-time notification through multiple
media, including SMS, email, and mobile apps. This connectivity ensures that users and
relevant parties receive timely alerts, regardless of their physical location, allowing for quicker
responses to potential emergencies. Furthermore, the use of machine learning algorithms within
the IoT-based system minimizes false alarms by distinguishing real fire threats from non-
threatening sources, enhancing reliability and reducing unnecessary disturbances.

In addition to detection and alerting, this system incorporates smart home functionality,
allowing it to interact with other devices to automatically trigger safety mechanisms. For
instance, in the presence of a dangerous element, the system can independently shut off
electricity, activate sprinklers, or initiate other automated safety responses. This level of
automation provides an additional layer of protection, minimizing the need for immediate
human intervention and potentially mitigating the threat even before first responders arrive.

The goal of this project is to create a flexible, adaptable design that can be implemented in
various types of buildings, including homes, offices, and other commercial spaces. This
versatility ensures that the system can improve safety across a wide range of settings, making
it suitable for diverse environments with differing fire safety needs. By combining advanced
detection capabilities, real-time connectivity, and automated safety responses, the IoT-based
Smart Smoke Detection System not only enhances safety but also represents a significant
advancement in fire prevention technology. This comprehensive approach ensures that users

3
have a reliable and proactive solution for safeguarding lives and property against fire-related
risks.

4
2. PROJECT DESCRIPTION AND GOALS

2.1. Literature review

1. AN ARCHITECTURAL APPROACH TOWARDS THE FUTURE INTERNET OF


THINGS Uckelmann, D., Harrison, M., & Michahelles, F. (2011)
This paper explores an architectural approach to the development of the Internet of Things
(IoT) as part of the future internet. It discusses the technological evolution of IoT, various
architectural models, and possible future applications, providing a foundation for
understanding how IoT will shape global communication and device interaction.

2.. SMART FIRE ALARM SYSTEM USING IOT AL Shereiqi, I. M., & mad Sohail,
M.(2020)
This research introduces a smart fire alarm system using IoT technologies. The authors
highlight the system's effectiveness in detecting fires in real-time and transmitting alerts
through IoT devices. The study focuses on how IoT can enhance fire prevention methods with
more accurate and timely responses.

3. APPLICATION OF NB-IOT IN INTELLIGENT FIRE PROTECTION SYSTEM Li,


T., &Hou,P.(2019)
This paper focuses on the application of Narrowband IoT (NB-IoT) in intelligent fire protection
systems. Presented at an international conference, the authors discuss how NB-IoT can be
utilized for monitoring and detecting fires in real-time, offering solutions for improving safety
in various environments through intelligent systems.

4. LOW-COMPLEXITY HIGH-PERFORMANCE DEEP LEARNING MODEL FOR


REAL-TIME LOW-COST EMBEDDED FIRE DETECTION SYSTEMS Jadon, A.,
Varshney, A., & Ansari, M. S. (2020)
The study presents a low-complexity, high-performance deep learning model designed for
embedded fire detection systems. The authors aim to create a low-cost and real-time fire
detection system that can operate effectively with limited resources, providing an innovative
approach to fire safety in IoT environments.

5. IOT-BASED INTELLIGENT MODELING OF SMART HOME ENVIRONMENT


FOR FIRE PREVENTION AND SAFETY Saeed, F., Paul, A., Rehman, A., Hong, W. H.,
& Seo, H.(2018) In this article, the authors develop an
IoT-based intelligent model for smart home environments, focusing on fire prevention and
safety. The system integrates various sensors to detect fire hazards and offers a scalable and
efficient solution for ensuring safety in smart homes through IoT technologies.

5
6. IOT-BASED FIRE ALARM SYSTEM Mahgoub, A., Tarrad, N., Elsherif, R., Al-Ali,
A., & Ismail, L. (2019)
This paper presents an IoT-based fire alarm system aimed at improving fire detection and
alerting capabilities. The authors discuss how IoT integration enhances traditional fire alarm
systems by allowing real-time monitoring and response, leading to better safety measures. The
system is tested in various environments to evaluate its efficiency and scalability.

7. WEBSERVER BASED SMART MONITORING SYSTEM USING ESP8266 NODE


MCU MODULE Aziz, D. A. (2018)
The author introduces a web server-based smart monitoring system using the ESP8266 Node
MCU module. This system facilitates remote monitoring and control of devices via the internet,
with a focus on smart environments such as homes or offices. The study highlights the
effectiveness of using IoT modules to create affordable and scalable smart monitoring
solutions.

8. CARBON NANOTUBE BASED MULTIFUNCTIONAL FLAME SENSOR Mohanty,


S., & Misra, A. (2014)
This research explores the use of carbon nanotube-based multifunctional flame sensors. The
sensors are designed to detect flames with high sensitivity and low power consumption. The
authors propose that such sensors can be integrated into IoT systems to provide early fire
detection in a variety of applications, improving safety and response times.

9. IOT FOR ENERGY EFFICIENT GREEN HIGHWAY LIGHTING SYSTEMS:


CHALLENGES AND ISSUES
Mukta, M. Y., Rahman, M. A., Asyhari, A. T., & Bhuiyan, M. Z. A. (2020)This
paper discusses the application of IoT for energy-efficient green highway lighting systems.
While primarily focusing on energy efficiency, the paper also touches on the challenges of
integrating IoT into infrastructure systems. The authors propose solutions to optimize lighting
based on traffic and environmental conditions, contributing to sustainabilityefforts.

10. REVERSIBLE TEMPERATURE-SENSITIVE LIQUID–SOLID


TRIBOELECTRIFICATION WITH POLYCAPROLACTONE MATERIAL FOR
WETTING MONITORING AND TEMPERATURE SENSING
Li, X., Zhang, L., Feng, Y., Zheng, Y., Wu, Z., Zhang, X., & Zhou, F. (2021)The
authors present a novel temperature-sensitive liquid-solid triboelectrification system for
wetting monitoring and temperature sensing. This research offers insights into how
triboelectric sensors can be used in IoT systems to detect environmental changes, which can be
applied in fire prevention or safety monitoring systems by tracking temperature fluctuations.

6
11. DATA COLLECTION METHODS SERIES: PART 4: DESIGNING FORMS AND
INSTRUMENTS Hutchinson, E., & Harwood, E. M. (2009)
This paper is part of a series focused on data collection methods, specifically discussing the
design of forms and instruments for effective data gathering. While not directly related to IoT,
the study offers valuable insights into how data collection tools can be optimized, which is
essential for IoT systems that rely on accurate data input for decision-making processes.

12. SOFTWARE DEVELOPMENT LIFECYCLE MODELS


Ruparelia, N. B. (2010)
This article outlines various software development lifecycle (SDLC) models, including their
strengths and weaknesses. The author compares traditional models such as Waterfall with more
flexible approaches like Agile, providing a comprehensive analysis that is useful for developing
IoT systems, which require robust and adaptable software structures.

13. WATERFALL VS. V-MODEL VS. AGILE: A COMPARATIVE STUDY ON SDLC


Balaji, S., & Murugaiyan, M. S. (2012)
The authors present a comparative study of three popular SDLC models: Waterfall, V-Model,
and Agile. Their findings help developers choose the right methodology depending on the
complexity and requirements of the project. In the context of IoT, the adaptability of Agile
might offer the best approach for evolving and iterative system development.

14. LOW-COMPLEXITY HIGH-PERFORMANCE DEEP LEARNING MODEL FOR


FIRE DETECTION SYSTEMS Jadon, A., Varshney, A., Ansari, M. S., & Kant, C. (2020)
This research focuses on the application of deep learning in fire detection systems, particularly
in environments constrained by computational resources. The authors propose a low-
complexity deep learning model for fire detection, which can be embedded into IoT devices.
This offers real-time monitoring and early detection of fire hazards, optimizing safety in
various IoT-enabled infrastructures.

15. IOT-BASED INTELLIGENT MODELING FOR FIRE PREVENTION AND


SAFETY IN SMART HOMES
Rehman, A., Saeed, F., Paul, A., & Hong, W. H. (2018)The
paper discusses IoT-based intelligent modeling for fire prevention and safety in smart homes.
The authors developed a model that integrates sensors and IoT devices to detect and respond
to fire hazards. Their approach enhances traditional fire alarm systems by offering real-time
monitoring and increased automation in smart environments.

7
2.2 Research Gap

1. Lack of Connectivity
More specifically, the traditional smoke detectors are standalone systems which are not
connected to a wider network or system. This leads to what they refer to as Localized alarms,
that is alarms restricted to the said device. This is more so in emergency situations whereby in
the event none of the respondents are near the alarm’s vicinity, the cycle will only begin after,
hence quite a number of minutes may be wasted. This delay is however dangerous since it may
deny the receiving party an opportunity to contain the situation thus leading to formation of a
physical barrier that can result in damage or even injury if an accident happens. There is no
way of sending a signal to those who are not in the vicinity of that location for example those
still out of their homes or in distinct parts of a huge compound. This isolation reduces the
efficiency of the smoke detection system in helping to respond to any probable fire risks on
time.

2. Limited Alert Mechanisms


Currently marketed smoke detector offer only audible notification such as loud alarm.
Although these alarms are efficient to wake those within vicinity, they may not be sufficient in
some occasions. For instance, if the occupants are asleep, in another room or out of the house,
the audio alert may not be effective. However, in such cases, there are no more alerting
mechanisms provided such as for visual, for sending alerts to the mobile devices, or integration
with other communication systems, so that the system is able to guarantee that all the concerned
parties are alerted timely. This limitation can becomes a drawback of the system especially
when quick decision has to be made.

3. No Real-Time Monitoring
There are a number of shortcomings with the conventional smoke detection systems including
the following Ones do not provide real-time monitoring or easy remote access. As mentioned
earlier, the lack of real time data makes it impossible for a user to access their property’s status
while on the move. Users are unable to monitor the fire risks or even the status of the system
in order to make a proper decision and take necessary action when needed due to the lack of
remote-monitoring. This lack of remote access also raises difficulties of users being able to
check on the operation of the system or receive any notifications on the detected threats and
subsequently, may result in users being unaware of the security condition of their property.

4. False Alarms
But one of the most common problems associated with the standard smoke detector is its
tendency to give a false alarm. It produces false alarms when it finds that it is in a position to
respond to non-threatening issues such as smoke from cooking, steam from shower, dust among
others. This results in alarm fatigue in which individuals and or system become insensitive to
the alerts hence compromising their usefulness. Such complacency may in the long-run reduce
the efficiency and effectiveness of this system to such a measure that its occupants do not react

8
as would be expected to actual fire incidents. One significant problem is that even triggers that
are not genuine threats cannot be identified from other challenges, which erodes the system’s
efficiency even more.

5. Lack of Integration
Conventional smoke detection systems are normally standalone and are not connected with
other smart home appliances and emergency services. This level of integration does not allow
the system to connect with other technologies including smart home and emergency services.
For instance, there are no default actions to execute upon threat detection including the shutoff
of electrical circuits, closure of sprinklers or calling the emergency services. Without such
integration, the system cannot effectively respond to fire dangers in an integrated and
automative manner which reduces the efficacy of the safety measures that are in place.

Modern Enhancements
Some of the modern Smoke Detection Systems have been manufactured with some basic
connectivity features such as Wi-Fi, or Bluetooth but these technologies are restricted. They
may allow simple things such as triggering notifications to mobile devices but normally are
inadequate in giving elaborate monitoring, enriched real time alarms, or synchronisation with
other smart home solutions. Such systems may also be missing intelligent learning features that
would help to minimize false alarms, based on a clear differentiation between risks and signs
of potential dangers as well as other stimuli. Therefore, even though there may be certains
changes in more modern systems, many of these systems experience numerous issues with
connectivity and alerting mechanisms, monitoring real time and integration.

9
2.3 Objectives

1. Enhance Connectivity: Connect smoke detectors with IoT so as to receive alert notifications
and monitor the building’s security through the use of mobile applications even when
occupants are not present.

2. Reduce False Alarms: Introduce variable control mechanisms that should allow the system
distinguish real fire events from other false alarms such as cooking, thereby enhancing system
effectiveness.

3. Provide Comprehensive Alerts: Create different modes of alerting that includes short
message service, email, and the mobile application that should alert the users and the
emergency services no matter the place they are.

4. Enable Smart Home Integration: Make the smoke detection system compatible with other
home appliances like the HVAC systems, sprinklers etc, to enable early safety measures like
stopping air circulation or turning on the sprinkler in case of threats as detected by the smoke
alarm.

5. Offer Scalability and Customization: Make the system adaptable to different areas including
residential use, commercial buildings and industries; the ability to vary different aspects of the
sensors and alerts used as well as the flexibility of the system in terms of compatibility.

10
2.4 Problem Statement

The existing smoke detection technologies have several significant limitations, with the most
notable being the inability to provide immediate alerts or self-learning capabilities.
Conventional smoke detectors, while effective within certain contexts, are typically standalone
network devices that can only trigger an alarm within the premises when smoke or fire is
detected. This becomes a critical issue in situations where no one is present to hear the alarm.
In such cases, a fire can go undetected for a significant amount of time, leading to extensive
property damage or even fatalities. This is especially dangerous because these systems, lacking
connectivity, cannot alert individuals outside the premises or summon emergency services on
their own.
Furthermore, conventional smoke detection systems are often prone to false alarms caused by
spurious conditions such as dust, steam from cooking, or fumes. These non-threatening sources
can easily trigger the alarm, creating a frequent disruption in the home or workplace. Over time,
users may become desensitized to these false alarms, which may lead to complacency in
responding to legitimate emergencies. This condition, known as alarm fatigue, significantly
reduces the effectiveness of traditional smoke detection systems in protecting lives and
property. As a result, when a real fire emergency occurs, users may ignore or delay their
response, exacerbating the situation.
Recognizing these challenges, this project aims to provide a solution through the creation of an
intelligent smoke detection system powered by IoT technology. By leveraging the connectivity
and advanced features of IoT, this system will offer real-time monitoring and alerts that can be
accessed remotely, even when individuals are not present at the location. The system will not
only detect smoke but also identify other potential fire hazards, such as toxic gases like carbon
monoxide, thereby providing a more comprehensive safety solution.
Incorporating **adaptive learning algorithms**, the system will be able to distinguish between
actual fire conditions and other non-threatening scenarios, significantly reducing the frequency
of false alarms. This feature improves the system's reliability, ensuring that users receive timely
and accurate alerts when genuine threats are detected. Moreover, the system can interact with
other smart home technologies, enabling automated responses to detected hazards. For
instance, if smoke or gas is detected, the system can automatically turn off electricity, activate
sprinklers, or alert emergency services, minimizing the damage caused by the fire and
enhancing safety.
One of the key advantages of the IoT-based smoke detection system is its **flexibility** in
terms of size and adaptability. The system can be tailored to fit various environments, including
residential homes, offices, commercial buildings, and industrial facilities. This scalability
ensures that the system can be customized to meet the specific needs of different users and
settings, providing a versatile solution to fire safety across a wide range of applications. By
integrating real-time alerts, adaptive learning, and smart home interaction, the system not only

11
addresses the limitations of traditional smoke detectors but also creates a more proactive and
efficient fire prevention and response mechanism

2.5 Project Plan

Phase 1: Research and Requirement


The first step therefore is to document and evaluate currently used smoke detection
technologies and the drawbacks associated with them. This includes understanding the current
systems in order to know the areas that are weak as well as the areas of strength. From this
analysis, it will be therefore possible to deduce the right hardware and software necessary for
the internet of Thing based Smoke Detection System. A Feasibility study will be conducted in
order to establish whether the project is technically and economically feasible while a Risk
analysis will be conducted to identify the risks likely to besete and measures to mitigate the
risks.

Phase-2: Design and the prototyping


The design and prototyping development phase also decrease but again the costs are split
between both the hardware and the software development. Based on aspects to be designed,
appropriate hardware will be purchased which include Node MCU, smoke sensors, flame
sensors, power supply units. These sensors will be connected in the circuit and PCB layout in
order to facilitate proper interfacing with the microcontroller. On the software side, they will
have the use of the embedded software generated in a language termed as Embedded C that
will undertake tasks of data acquisition and processing of information from the sensors.
Moreover, the cloud infrastructure and the mobile application will be built in order to support
real-time monitoring & notification.

Phase 3:Implementation and Development


This phase also encompasses the mechanics of carrying out these detailed development
processes especially through project implementation. In the implementation and development
stage, it entails bringing together the hardware components of the assembled system into a
working prototype. The actual code to use in Node MCU will be coded, while the cloud-based
platform as well as the mobile application will be designed. To special system accuracy and
minimize false alarms machine learning algorithms will be used. The hardware will be
interfaced with home intelligent devices and tests will conducted on how the hardware interacts
with the software and the cloud services.

Phase 4: Testing and Validation


The evaluation and control phase entails performing unit testing of various components so as
to confirm that they work. Final Acceptance testing will be carried out so as to verify
interoperability among the sub system. The system will be exercised in several conditions in
order to guarantee that the smoke is detected correctly, and the alerts are issued on time and
the smart home integration works as expected. There will be an optimization process of the
power consumption as well as the performance.

12
Phase 5: Deployment and Documentation
In this phase, the real environment, for instance, a home or office environment will be used to
disseminate the system. Feedback will also be taken to evaluateorexamine and observe
andassess certain performances and, if needed, to fine-tune them. Several user guides, technical
descriptions, and installations’ instructions will be provided to the buyers allowing them to
understand how the system operates and how to deploy it.

Phase 6: Maintenance and Support


The last process seems to be the maintenance of the implemented system in order to guarantee
its efficiency in the long run. There will be supervising of the system to identify the problems
and then they will be solved in this way. For improvement measures, feedback from the users
will be sought in the attempt to find ways of improving the system in future enhancements and
expansion.

13
3. TECHNICAL SPECIFICATION

3.1 Requirements

3.1.1 Functional

• Hazard Detection: The system utilizes advanced sensors to detect various hazards such as
smoke, toxic gases (e.g., carbon monoxide), and flames in real-time. The integration of multiple
sensors ensures comprehensive monitoring of potential fire risks, providing early detection of
smoke and hazardous conditions. These sensors continuously scan the environment and trigger
alarms or notifications when danger is detected, thereby preventing the spread of fire and
reducing the risk to life and property.

• Data Processing: The Node MCU, acting as the central controller, processes data from the
smoke, gas, and flame sensors. This microcontroller is responsible for collecting sensor
readings and analyzing them to identify potential threats. The Node MCU is connected to a
cloud platform via Wi-Fi, enabling it to send processed data and trigger alerts. The cloud
platform allows for further processing, real-time monitoring, and access to historical data,
which can help in improving system performance over time.

• Real-Time Alerts: Upon detecting a fire hazard, the system sends instant alerts to users via
SMS, email, or mobile notifications. These alerts are designed to reach users immediately,
regardless of their location, ensuring that they are informed about potential threats. This feature
is particularly beneficial when users are not on-site, as it enables them to take action from
anywhere—alerting local authorities, taking preventive measures, or alerting family members
or colleagues.

• False Alarm Reduction: To improve the reliability of the system, machine learning
algorithms are used to differentiate between real fire threats and non-threatening conditions
(such as steam from cooking or dust). By analyzing data trends and environmental patterns, the
system learns to recognize typical scenarios that lead to false alarms and fine-tunes its detection
processes, thus significantly reducing unnecessary alerts and minimizing user disturbance. This
adaptive approach ensures that only genuine fire threats trigger alarms.

• Cloud Storage: All sensor data, including environmental readings, detected hazards, and
system performance logs, are stored securely in the cloud. Cloud storage provides several

14
benefits, including easy access to historical data for analysis, system diagnostics, and
performance tracking. It also allows for remote monitoring of the system, providing users with
the ability to check the status of their home or business at any time. Cloud storage ensures data
persistence, allowing users and administrators to review past events in the case of an incident.

• User Interface: The system includes a user-friendly mobile or web application for monitoring
and controlling the smoke detection system. Through this interface, users can view real-time
sensor data, receive alerts, and customize alert settings according to their preferences. For
instance, users can set thresholds for when alerts are triggered or modify the type of
notifications they receive. The app also allows for seamless interaction with other smart
devices, enabling users to manage their environment and take necessary actions directly from
their mobile or web interface.

• Automated Responses: The system is designed to integrate with other smart home or
building devices to automatically take preventive actions when a threat is detected. For
example, if smoke or gas is detected, the system can automatically shut off electrical circuits
to prevent electrical fires, or it can activate sprinklers or other fire suppression systems. This
automation minimizes the need for immediate human intervention, allowing the system to
respond to hazards more quickly and efficiently, reducing damage and improving safety.

• Emergency Integration: The system can be configured to alert local emergency services in
the event of a fire. Once a fire hazard is detected, the system can automatically notify fire
departments or emergency responders, providing them with critical information such as the
type of hazard and the location of the affected area. This integration ensures a faster response
time from emergency services and enhances the overall effectiveness of the system in
mitigating damage and protecting lives.

• Power Management: To ensure continuous operation even in case of power outages, the
system is equipped with a reliable backup power solution. This can include batteries or other
power sources that automatically engage when the main power supply fails. The backup power
ensures that the system remains functional during emergencies, providing uninterrupted
monitoring, alerting, and data transmission to the cloud, ensuring reliability and reducing the
risk of system failure during critical times.

• Data Security: The system uses secure transmission protocols to protect the data being sent
between sensors, the Node MCU, and the cloud platform. Encryption methods are employed
to safeguard sensitive data, ensuring that personal information and system data are protected
from unauthorized access or tampering. Additionally, the system adheres to best practices for
data security, including regular software updates and secure cloud storage, to maintain the
integrity and confidentiality of user data.

15
3.1.2 Non-Functional

• Performance: The system is designed to detect fire hazards, such as smoke, gas, or flames,
and send alerts to users within 2 seconds of detecting a threat. This quick response time is
crucial for minimizing potential damage and ensuring timely action can be taken. Whether the
system is alerting users via SMS, email, or mobile notifications, the goal is to provide near-
instantaneous communication to enhance safety.

• Reliability: The system aims to maintain a 99.9% uptime, ensuring that it is always functional
and capable of detecting threats at all times. Consistent alert delivery is essential, particularly
in emergency situations, so the system is engineered with robust components and cloud
infrastructure that support high availability and minimal downtime, ensuring that alerts are
never missed when they are most needed.

• Scalability: The system is designed to scale according to user needs. It can support the
addition of more sensors or even multiple sites, making it adaptable to different environments,
whether it’s a single home, a multi-room office, or an entire industrial complex. This scalability
ensures that the system can grow alongside the needs of the user, allowing for easy expansion
without compromising performance.

• Usability: The user interface is designed with simplicity and ease of use in mind. The system
provides a mobile or web application where users can monitor sensor data, receive alerts, and
configure the system without technical expertise. The interface offers intuitive navigation, clear
alerts, and easy setup, ensuring that even non-technical users can manage and control the
system effectively.

• Security: To protect user data and system integrity, the system employs strong encryption
protocols for data transmission. User authentication is required to access the system, ensuring
that only authorized individuals can control or modify system settings. This level of security is
essential in preventing unauthorized access, tampering, or misuse of the smoke detection
system, particularly as it handles sensitive data about the user's environment and potential
hazards.

• Maintainability: The system allows for easy maintenance and updates through Over-The-
Air (OTA) capabilities. This means that software updates, security patches, and new features
can be delivered remotely, ensuring the system stays current with minimal effort. Additionally,
the system is designed to be user-friendly for maintenance, with clear diagnostics and alerts
that help users identify and resolve issues quickly.

• Power Efficiency: The system is engineered to be energy-efficient, with features designed to


minimize power consumption. By using low-power sensors and optimizing data transmission,
the system can run for extended periods without depleting the battery. The system’s power

16
management strategies are particularly important for devices that rely on battery power,
ensuring that the smoke detection system remains operational even in low-power conditions.

• Interoperability: One of the key strengths of the IoT-based smoke detection system is its
ability to integrate with other smart devices and platforms. The system can work in conjunction
with other home automation technologies, such as smart lighting, thermostats, or security
systems. Integration with third-party services and platforms like Amazon Alexa, Google Home,
or other smart home hubs allows users to control and monitor their system seamlessly from
various devices and applications, enhancing convenience and expanding functionality.

• Compliance: The system is designed to meet all regional safety and privacy standards,
including fire safety regulations and data protection laws. Whether for residential, commercial,
or industrial use, the system ensures that it complies with the relevant codes and standards,
including ensuring that it meets specific privacy requirements for storing and transmitting user
data. This compliance assures users that the system adheres to established safety protocols and
legal guidelines.

• Availability: In the event of a power outage or failure, the system is equipped with a backup
power solution, such as a battery or an uninterruptible power supply (UPS). This ensures that
the smoke detection system remains operational even when the primary power source is
unavailable, continuing to monitor hazards, send alerts, and store data without interruption.
This availability is critical for ensuring the system can function continuously, especially during
emergency situations when power is most likely to be disrupted.

3.2 Feasibility Study

3.2.1 Technical Feasibility

• Hardware: The use of affordable and compatible sensors, such as the MQ-2 smoke sensor
and flame sensors, paired with the ESP8266 microcontroller, ensures real-time smoke and gas
detection. These sensors are widely available and have proven efficacy in detecting smoke,
carbon monoxide, and other hazardous gases, making them suitable for deployment in various
environments. The ESP8266 microcontroller offers robust Wi-Fi capabilities, allowing the
system to connect seamlessly to the internet for cloud integration and real-time monitoring.

• Cloud Integration: By utilizing the Blynk platform, the system benefits from seamless cloud
connectivity, enabling real-time data monitoring and alerting through mobile applications.
Blynk's cloud services provide easy-to-use interfaces for managing the smoke detectionsystem,
sending instant notifications to users, and ensuring that alerts are sent regardless of their
geographical location. This reduces the complexity and cost of building custom cloud
infrastructure.

17
• False Alarm Reduction: Basic machine learning algorithms integrated into the Blynk
platform can effectively minimize false alarms. These algorithms analyze data trends from the
sensors and identify patterns that typically cause false positives, such as cooking smoke or
steam. By distinguishing between actual fire threats and benign conditions, the system reduces
alarm fatigue and ensures that users receive only relevant alerts.

• Power Supply: The system is designed with reliability in mind, offering a steady power
supply with battery backup to ensure continuous operation. This ensures that even during
power outages, the smoke detection system remains operational, providing uninterrupted
monitoring and alerting capabilities, which is critical for real-time safety.

• Network and Security: The ESP8266’s Wi-Fi connectivity ensures that the system remains
connected to the cloud for real-time data transmission and alert delivery. To address security
concerns, data transmission between the device and cloud is encrypted, ensuring that sensitive
user information and sensor data are protected against unauthorized access. The system adheres
to best practices in network security, ensuring reliable connectivity and safeguarding user
privacy.

3.2.2 Economic Feasibility

• Low-Cost Hardware: The hardware components, including the ESP8266 microcontroller,


MQ-2 smoke sensor, and flame sensors, are affordable and readily available. These low-cost
components help keep the initial setup costs low while still providing reliable and effective fire
detection. This makes the system economically viable for both residential and commercial use.

• Cloud and App Integration: By utilizing Blynk’s platform for cloud integration and mobile
app functionality, the system avoids the need for expensive custom development. Blynk offers
an easy-to-use, ready-made solution for monitoring and sending alerts, reducing the
development costs and time required to deploy the system. Additionally, using Blynk
minimizes the need for additional server infrastructure, further lowering costs.

• Minimal Maintenance: The system’s simple design ensures that it requires minimal
maintenance. Regular software updates can be performed remotely through Over-The-Air
(OTA) functionality, which reduces the need for physical interventions or expensive
maintenance. This feature ensures that the system can stay up to date with the latest features
and security patches, lowering the long-term costs associated with maintaining the system.

• Energy Efficiency: The system is designed with energy efficiency in mind. Low-power
components such as the ESP8266 and MQ-2 sensor ensure that the system consumes minimal
power, keeping operational costs low. The inclusion of battery backup means that the system

18
can continue functioning during power outages, but the system is optimized for minimal energy
consumption, extending battery life and reducing energy bills.

• Scalability: The system is highly scalable, with affordable components making it cost-
effective to expand. As the need for additional coverage arises (e.g., in larger homes, office
buildings, or industrial sites), more sensors can be added without significantly increasing costs.
This scalability ensures that the system can grow with the needs of the user, providing a cost-
effective solution for a wide range of environments.

3.2.3 Social Feasibility

• Enhanced Safety: The IoT-based smart smoke detection system improves safety by
providing faster hazard detection and immediate alerts, reducing the likelihood of
property damage or loss of life. In emergencies, the ability to send instant notifications
to users ensures that they can act quickly, preventing fires from escalating. This is
particularly beneficial in areas where people may not be present, such as during work
hours or when traveling.
• Ease of Use: Blynk’s user-friendly mobile and web applications make it easy for non-
technical users to monitor the smoke detection system, manage alerts, and make
necessary adjustments. The interface is intuitive, ensuring that anyone, regardless of
technical background, can easily interact with the system. This promotes widespread
adoption among users who may be unfamiliar with more complex smoke detection
technologies.
• Increased Awareness: Real-time notifications increase user awareness of potential fire
hazards, encouraging proactive safety measures. The system helps users stay informed
about the safety of their environment, prompting them to take action when risks are
detected. This heightened awareness fosters a culture of safety, helping prevent
emergencies before they happen.
• Integration with Smart Homes: The system is compatible with other smart devices
and home automation systems, allowing for seamless integration with technologies like
smart thermostats, lights, or security cameras. This integration improves convenience,
as users can manage the smoke detection system along with other home automation
features. For example, when smoke is detected, the system can trigger automated
responses such as turning off power to prevent electrical fires or activating sprinklers.
• Community Impact: The deployment of this system can have a significant positive
impact on public health and safety. By reducing fire risks and improving detection
times, the system helps prevent fires from spreading, reducing the potential for injury
or death. Furthermore, the system’s ability to alert emergency services can lead to faster
response times, enhancing community safety. The widespread use of such systems can
also reduce the strain on local emergency services by mitigating the scale of fire-related
incidents, ultimately contributing to safer communities.

19
3.3 System Specification

3.3.1 Hardware Specification

NodeMCU ESP8266
MQ2 Sensor
0.96" I2C OLED Display
Buzzer
5mm LED
Zero PCB board
Flame senser ky-026
DHT11 Temperature & Humidity Sensor
2pin Terminal Connectors
LDR Light Sensor
3.3.2 Software Specification

Embedded C Programming: Software for the Node MCU to control sensors, process
data, and handle communications with the cloud.

IoT Platform: Integration with an IoT platform, Blynk for cloud connectivity, data
processing, and alert management.

Machine Learning Algorithms: Implemented in the software to reduce false


alarms and enhance detection accuracy.

Mobile Application: For remote monitoring, alert management, and system control
by the user

20
4. DESIGN APPROACH AND DETAILS

4.1 System Architecture

This diagram represents an IoT (Internet of Things) system utilizing the NODE MCU, which
is based on the ESP8266 microcontroller. Here's a breakdown of the components and their
functions:

1. NODE MCU: Central microcontroller that processes inputs from various sensors and
communicates with the cloud server.

2. Sensors:

o Smoke Sensor: Detects the presence of smoke in the environment.


o Flame Sensor: Identifies flames or fire by detecting infrared radiation.
o Humidity Sensor: Measures the moisture level in the air.
o Temperature Sensor: Monitors ambient temperature.

3. Embedded C Programming: The programming language used to develop software for


the NODE MCU that enables it to read sensor data, process it, and communicate with
other devices.

4. Cloud Server (Blink IoT): A platform that enables data storage and monitoring of the
sensor data through the internet, allowing remote access and analysis.

5. Machine Learning Algorithms: These may be used to analyze the sensor data, predict
patterns, or automate responses based on the data received.

6. Rectifiers: These convert alternating current (AC) to direct current (DC), which is
typically required to power electronic circuits.

21
7. Power Supply: Provides the necessary electrical energy for the NODE MCU and
connected sensors.

Overall, this setup could be used for applications such as fire detection and monitoring systems,
enabling real-time alerts and data logging through cloud connectivity.

Software Requirements
1. Arduino IDE: To write and upload the code to the NodeMCU.
2. Blynk IoT App: For creating a user interface and real-time monitoring on a mobile
device.
3. Blynk Library: To connect the NodeMCU with the Blynk cloud server.
4. Wi-Fi Connection: For data communication between the NodeMCU and Blynk cloud.
Steps to Implement the System
Step 1: Setup Blynk Account
1. Download the Blynk App: Available on both Android and iOS.
2. Create an Account: Sign up using your email or log in if you already have an account.
3. Create a New Project:
o Give your project a name, e.g., "Smart Smoke Detector".
o Select ESP8266 as the device model.
o Choose a connection type (Wi-Fi).
o An Auth Token will be sent to your email, which is necessary for connecting
the NodeMCU with the Blynk app.
Step 2: Configure Widgets in Blynk App
1. Add Widgets:
o Gauge: For temperature readings.
o Label Display: To show humidity levels.
o LED: For smoke and flame detection indicators.
o Notification: For sending alerts when smoke or fire is detected.
2. Assign Virtual Pins:
o Smoke Sensor: V3
o Flame Sensor: V4
Step 3: Circuit Connection
• Connect the DHT11/DHT22 (temperature and humidity sensor) to the NodeMCU:
o VCC to 3.3V
o GND to GND
o Data pin to D5
• Connect the MQ2 Smoke Sensor:
o VCC to 3.3V
o GND to GND
o Digital Out to D6
• Connect the Flame Sensor:
o VCC to 3.3V
o GND to GND

22
o Digital Out to D7
• Power the NodeMCU using a 5V USB power supply or a regulated 3.3V-5V DC power
source.
Step 4: Programming the NodeMCU
1. Install the Blynk Library in the Arduino IDE:
o Open the Library Manager (Sketch > Include Library > Manage Libraries).
o Search for Blynk and install it.
o Also, install the DHT sensor library if you are using a DHT11/DHT22 sensor.
2. Code Implementation: Embedded C code for the NodeMCU to read sensor data and
send it to the Blynk cloud.
Step 5: Uploading Code to NodeMCU
1. Connect NodeMCU to the computer via USB.
2. Select Board and Port:
o Go to Tools > Board and choose NodeMCU 1.0 (ESP-12E Module).
o Set the correct COM Port in Tools > Port.
3. Upload the Code by clicking the Upload button.
Step 6: Testing the System
1. Open the Serial Monitor in the Arduino IDE to check sensor readings.
2. Check Blynk App:
o Open the Blynk app on your phone.
o Start the project by pressing the play button.
o Monitor temperature, humidity, smoke, and flame detection in real-time.
o Receive notifications if smoke or flame is detected.
Explanation of the Code
1. Initialization:
o The NodeMCU connects to Wi-Fi using the provided credentials.
o The DHT sensor, MQ2 sensor, and flame sensor pins are configured.
2. Sensor Reading:
o The readSensors function reads temperature and humidity from the DHT sensor.
o It checks for smoke and flame detection using digital reads from the MQ2 and
flame sensor pins.
3. Data Transmission:
o The data is sent to Blynk using Blynk.virtualWrite(), allowing real-time updates
on the mobile app.
o Notifications are triggered using Blynk.notify() if smoke or flame is detected.
4. Blynk Timer:
o The Blynk timer is used to periodically execute the readSensors function every
2 seconds.
Key Features of the System
• Real-time Monitoring: Temperature, humidity, and smoke levels are displayed on the
Blynk app in real-time.

23
• Instant Alerts: Users receive instant notifications on their mobile devices if smoke or
fire is detected.
• Remote Access: The system can be monitored from anywhere in the world using the
Blynk app.
Possible Enhancements
1. Machine Learning Integration: Use machine learning algorithms to analyze the
collected data and predict potential fire hazards based on patterns.
2. Data Logging: Store historical sensor data in the cloud for further analysis and
visualization.
3. Advanced Alerts: Integrate with other services (e.g., email, SMS, or voice calls) for
more robust alert mechanisms.

24
4.2 Design

4.2.1 Data Flow Diagram

25
4.2.2 Use Case Diagram

26
4.2.3 Class Diagram

27
4.2.4 Sequence Diagram

28
5. METHODOLOGY AND TESTING

System Design:

The IoT-based Smart Smoke Detection System will integrate several critical components for
real-time hazard detection. The core of the system will be the ESP8266 microcontroller, which
acts as the main processing unit. The ESP8266 will be connected to various sensors including
the MQ-2 smoke sensor, gas sensors for toxic gases like carbon monoxide, and flame sensors
for detecting fire through infrared light. These sensors will continuously monitor the
environment for hazardous events. When any dangerous condition is detected, the ESP8266
will process the sensor data and send it to a cloud platform such as Blynk, which allows for
remote monitoring and real-time notifications. This design ensures that the system can monitor
environmental changes and alert users instantly, regardless of their location, via the Blynk
mobile or web app.

Sensor Calibration:

To ensure the accuracy and reliability of the detection system, it is essential to calibrate the
sensors correctly. Each sensor, such as the MQ-2 or flame sensor, will be calibrated to provide
accurate readings under normal and hazardous conditions. This involves adjusting the sensor's
response to environmental factors like humidity, temperature, and airborne particles to
minimize false alarms caused by non-threatening activities like cooking or dust. Calibration
ensures that the system only triggers alerts when it detects actual threats, reducing the chances
of alarm fatigue and enhancing user confidence in the system’s reliability.

Alert Configuration:

Once the sensors are calibrated and the system is set up, the next step is to configure alert
settings to suit the user's needs. The system will be designed to send notifications to the user
when it detects a hazardous event. Alerts can be customized based on sensor thresholds,
allowing users to set specific levels for when smoke, gas, or flames trigger an alarm. These
alerts will be sent through various channels such as SMS, email, or mobile app notifications
via the Blynk platform. This provides users with multiple ways to stay informed about potential
dangers, whether they are at home, at work, or on the go. The ability to customize the alerts
ensures that users receive timely notifications without being overwhelmed by false positives.

Smart Device Integration:

To enhance safety and automate responses, the system will integrate with other smart devices
within the home or office environment. The system can be programmed to automatically trigger
actions when a fire or hazard is detected. For example, if the smoke sensor detects a certain
threshold of smoke, the system can turn off electrical circuits to prevent electrical fires or

29
activate sprinklers to suppress the fire. Other automated responses may include turning on
emergency lights or unlocking doors for quick evacuation. This integration of the smoke
detection system with other smart devices provides an extra layer of security and reduces the
need for manual intervention during critical situations.

Machine Learning:

One of the key features of this IoT-based smoke detection system is its use of basic machine
learning algorithms to minimize false alarms. Through data analysis, the system will be able to
recognize patterns in the sensor data to differentiate between actual fire threats and benign
situations such as cooking or steam. For instance, if the system detects smoke in the kitchen,
machine learning algorithms can determine whether it is from cooking activities or a potential
fire hazard. Over time, the system will improve its accuracy and reduce the frequency of false
alerts by learning from past incidents. This machine learning component ensures that the
system not only provides accurate real-time alerts but also becomes smarter and more reliable
with continued use.

Problem Definition:
The task is to classify fire types (e.g., electrical, wood, chemical) using real-time
sensor data, including smoke density and temperature, and send alerts based
on detection.
Data Collection:
Gather data from sensors (smoke, flame, temperature, humidity) using devices
like Node MCU (ESP8266) under various fire conditions.
Data Preprocessing:
Clean the data by removing noise, handling missing values, and normalizing
sensor readings. Feature engineering creates new features like smoke rise rate
and time trends.
Model Selection:
Train a Random Forest model for multi-class classification, which is well-suited
to handling complex sensor data.
Model Training:
Split the data into training/testing sets, apply cross-validation, and optimize the
model using grid search for hyperparameter tuning.
Evaluation:
Use metrics like ROC Curve, AUC, Confusion Matrix, and Classification Report
to assess classification accuracy from all thresholds and reduce false alarms.
Real-Time Detection:
Deploy the model in an IoT setup, continuously monitoring and classifying fire
types in real-time. Alerts are sent via SMS or app notifications.

30
Smart Integration:
Connect the smoke detector with smart home systems to trigger safety actions like
turning off electrical circuits or activating sprinklers.
Continuous Learning:
Regularly update the model with new sensor data to improve performance and
further reduce false positives.
TESTING:

Unit Testing:

Unit testing involves testing individual components of the system to ensure they function
correctly in isolation. For this IoT-based smart smoke detection system, unit tests will be
conducted on each major hardware and software component. This includes:

• Sensors (MQ-2, Flame Sensor, Gas Sensor): Testing the accuracy of sensor readings
in different environmental conditions to ensure that they are detecting smoke, gas, or
flame correctly. Calibration procedures will be checked to minimize false positives and
ensure reliable performance.
• Node MCU (ESP8266): Testing the Node MCU microcontroller to ensure it can read
data from sensors, process it, and communicate with the cloud. This involves verifying
the stability of the Wi-Fi connection, the ability to transmit data accurately to the cloud,
and handling sensor data effectively.
• Mobile Application (Blynk): Ensuring that the Blynk app is receiving and displaying
real-time alerts from the Node MCU. The app's functionalities, such as receiving
notifications, displaying sensor data, and allowing the user to manage settings, will also
be tested.

Unit tests help identify issues early in the development process by focusing on each component
in isolation, ensuring they work correctly before proceeding to more complex integration
scenarios.

Integration Testing:

Integration testing ensures that different components of the system work together seamlessly.
This is crucial for ensuring that the hardware, software, and cloud platform function as a
cohesive system. Key integration testing scenarios will include:

• Sensor to Node MCU Communication: Verifying that data from sensors is being sent
accurately to the Node MCU and that the microcontroller can process and interpret the
data correctly.
• Node MCU to Cloud (Blynk): Testing the connection between the Node MCU and the
Blynk cloud platform. Ensuring that sensor data from the Node MCU is transmitted to

31
Blynk in real-time and that alerts are triggered properly on the Blynk app when
thresholds are reached.
• Cloud to User Interface: Ensuring that data from the cloud is presented properly on
the mobile or web app, with correct sensor readings and notifications displayed in real
time. Any errors in data synchronization or display will be identified during integration
testing.

Integration testing ensures that all components of the system work well together and
communicate effectively, which is crucial for system reliability.

Functional Testing:

Functional testing verifies that the system works as intended and meets its functional
requirements. In the context of the smart smoke detection system, this involves:

• Alert Triggers: Verifying that alerts are triggered correctly when specific smoke, gas,
or flame detection thresholds are met. For instance, the system should send a
notification when smoke levels reach a certain threshold, gas concentrations are
dangerous, or a flame is detected.
• Automated Actions: Ensuring that automated responses, such as turning off electrical
circuits or activating sprinklers, are triggered correctly when hazards are detected. This
includes checking the integration of the smoke detection system with other smart home
devices.
• Real-Time Notification: Testing that SMS, email, and app notifications are sent
instantly when a hazardous situation is detected. The system should be capable of
sending timely alerts to users regardless of their location.

Functional testing ensures that the smoke detection system performs the tasks it was designed
for and meets user expectations for performance and behavior.

Performance Testing:

Performance testing ensures that the system operates efficiently and can handle real-time
requirements. This is crucial for a smoke detection system where timely responses are critical.
Key aspects of performance testing include:

• Alert Response Time: Verifying that the system sends alerts within 2-3 seconds of
detecting smoke, gas, or flame. This is important to ensure that users receive real-time
notifications and can take quick action.
• System Load Handling: Testing the system's ability to process and transmit data
without lag or delay. This includes ensuring that the Node MCU and cloud platform
can handle multiple sensors or concurrent alerts without performance degradation.

32
Performance testing ensures that the system can deliver real-time notifications and handle
various environmental conditions without delays, which is essential for maintaining safety.

Security Testing:

Security testing ensures that the system is secure and that users’ data is protected from
unauthorized access. In the context of the IoT-based smoke detection system, this includes:

• Encryption: Testing the encryption of data transmitted between the Node MCU, cloud
platform, and the mobile app to ensure that sensitive information is protected from
interception.
• Authentication: Verifying that the user authentication mechanisms on the Blynk app
and cloud platform are secure. This includes ensuring that users can only access their
own data and settings, and that unauthorized access is prevented.
• Data Integrity: Ensuring that data transmitted from the sensors to the cloud and app
remains intact and hasn’t been tampered with during transmission.

Security testing ensures that the system is protected from potential cyber threats, ensuring users'
privacy and the integrity of sensor data.

User Acceptance Testing (UAT):

User Acceptance Testing (UAT) is conducted to ensure that the system meets the needs of the
end user and that the system is easy to use. This testing will focus on:

• User Interface: Verifying that the mobile/web app has a user-friendly design, is easy
to navigate, and clearly presents sensor data and alerts. The system should be intuitive,
allowing users to manage and customize settings without difficulty.
• Ease of Use: Ensuring that users can easily set up the system, calibrate sensors,
configure alert thresholds, and integrate with other smart devices. The system should
not require advanced technical knowledge, and users should be able to interact with it
with minimal effort.
• Customer Feedback: Collecting feedback from users during testing to ensure that the
system provides a positive user experience, and to identify areas for improvement.

UAT helps ensure that the system is not only functional but also user-friendly, making it
accessible for all users, including those with minimal technical experience.

Stress Testing:

Stress testing ensures that the system can handle extreme conditions and still function reliably.
In the case of the smoke detection system, this includes:

33
• Multiple Alerts: Testing the system’s ability to handle multiple simultaneous alerts
from different sensors. For example, if multiple sensors detect smoke or gas at the same
time, the system should be able to process and alert users without crashing or becoming
unresponsive.
• High Traffic: Simulating high traffic to test the stability of the cloud platform when it
receives a large volume of sensor data and alerts. The system should be able to handle
peak usage times without slowdowns or failures.
• Long-Term Operation: Testing the system’s performance over extended periods of
use to ensure that it remains stable and reliable without degradation in
performance.Stress testing ensures that the system can operate under heavy load

34
6. PROJECT DEMONSTRATION

Fig 1

35
36
Fig 2

37
Fig 3

38
39
Fig 4

40
7. RESULT AND DISCUSSION

An Internet of Things (IoT)-based intelligent smoke detection system is a cutting-edge solution


for fire hazard management, leveraging real-time monitoring, cloud connectivity, and
automated responses. This innovative approach surpasses traditional systems by providing
enhanced safety, cost-effectiveness, and advanced functionality, meeting the needs of
residential, commercial, and industrial environments.

Advanced Detection and Multi-Risk Functionality

This system employs advanced sensors, including an MQ-2 smoke and gas sensor and a flame
sensor. The MQ-2 sensor is capable of detecting smoke and hazardous gases such as carbon
monoxide (CO) and liquefied petroleum gas (LPG), ensuring comprehensive fire risk
monitoring. Additionally, the flame sensor identifies flames quickly, improving response times
in fire situations. Unlike traditional detection methods, which may only alert occupants to
smoke or fire, this multi-risk system provides an extensive safeguard.

The ESP8266 microcontroller enables real-time communication with cloud platforms like
Blynk, allowing data transfer and alert notifications through SMS, email, or mobile
applications. This seamless integration provides instant alerts, letting users react to fire risks
immediately. Coupling this with machine learning algorithms reduces false alarms, ensuring
the system’s reliability and responsiveness.

Performance Testing and Energy Efficiency

In performance testing, the system consistently responded to fire threats within 2-3 seconds,
providing near-instant alerts and allowing users to act quickly. The device is also optimized for
energy efficiency, operating continuously with low power consumption. This design is
especially suitable for IoT-based systems where energy savings are critical, reducing
operational costs and extending system lifespan, making it highly suitable for both residential
and industrial spaces.

Intelligent Integration with Smart Devices

The system’s intelligence expands through its integration with other smart home appliances.
For example, upon detecting a fire, the system can automatically activate sprinklers or
disconnect electrical circuits to prevent further damage or the spread of fire. This added layer

41
of automated response not only strengthens fire management but also aligns with the trend of
smart home automation, enhancing the system’s appeal among tech-savvy users.

Cost Analysis

The total hardware cost is approximately 700 INR, making it highly affordable and accessible
for a broad range of users. Key components and their costs are as follows:

ESP8266 Node MCU (150 INR): This microcontroller acts as the system’s "brain," managing
sensor data and enabling cloud communication.

MQ-2 Smoke and Gas Sensor (150 INR): Detects smoke and hazardous gases such as CO and
LPG.

Flame Sensor (100 INR): Detects flames using infrared technology.

Power Supply (150 INR): Provides backup power during outages to maintain system
functionality.

Optional Sensors (100 INR): Additional environmental sensors, like temperature and humidity
sensors, provide detailed environmental data for enhanced functionality.

Miscellaneous Components (50 INR): This includes wiring, resistors, and other small
electronic parts.

This cost-effective pricing model ensures accessibility, making it an ideal solution for
households, small businesses, and even larger facilities that seek an affordable fire detection
system.

Operational Costs

The system incurs minimal operational costs due to its low-power design and affordable cloud
connectivity options. Cloud platforms like Blynk offer free basic monitoring services, with
minimal subscription fees for advanced features. This is especially appealing to home users
and small businesses, as it reduces ongoing costs compared to traditional fire detection systems,
which often require expensive hardware or monitoring services.

Practical Deployment and Scalability

The IoT-based smoke detection system is versatile, affordable, and scalable, with low
installation and maintenance costs. It is easily adaptable for diverse settings—residential,
commercial, and industrial—and can be expanded with additional sensors or larger coverage
areas as needed. Its scalability makes it an ideal choice for safeguarding both small and large
spaces, from individual households to industrial facilities.

42
Enhanced Safety and Future-Proof Design

Overall, the IoT-based smoke detection system offers a comprehensive, intelligent solution for
fire safety. Its advanced sensors, real-time cloud connectivity, and integration with smart
devices provide a proactive approach to fire risk management. With a low initial cost, energy-
efficient operation, and scalability, it is designed to meet the demands of modern users, making
it a highly attractive option for those seeking advanced fire protection.

In summary, this IoT smoke detection system is not only an effective fire safety solution but
also a future-proof addition to any environment, aligning with the trend of home and workplace
automation. By minimizing property damage and protecting lives, it brings peace of mind to
users, making it a valuable tool for modern fire safety management.

43
8. CONCLUSION
Fire hazards pose a significant risk to both residential and commercial properties, often
resulting in severe damage and loss. Traditional smoke detectors provide limited capabilities,
usually just triggering a local alarm. To enhance fire safety, the IoT-based Smart Smoke
Detection System leverages modern technology, integrating multiple sensors, a central
microcontroller (NODE MCU based on ESP8266), cloud connectivity, and real-time
notifications. This system offers a proactive approach to fire detection by providing timely
alerts and remote monitoring, ensuring swift action can be taken in case of a potential fire.
System Components and Their Functions
1. NODE MCU (ESP8266 Microcontroller)
The NODE MCU is the central component of the system, acting as the brain that processes data
from various sensors. It is a versatile microcontroller equipped with built-in Wi-Fi, allowing
seamless communication with cloud platforms. The NODE MCU reads data from theconnected
sensors, analyzes it, and sends relevant information to the cloud for remote monitoring.
2. Sensors
The smoke detection system utilizes several key sensors to comprehensively monitor
environmental conditions and detect potential fire hazards:
• MQ-2 Smoke Sensor: This sensor detects harmful gases such as smoke, carbon
monoxide, and liquefied petroleum gas (LPG). It operates by measuring gas
concentration levels in the air, triggering an alert if these exceed a predefined threshold.
• Flame Sensor: The flame sensor identifies the presence of flames or fire by detecting
infrared radiation emitted by burning objects. It provides a rapid response in case of
visible flames, contributing to early fire detection.
• Temperature Sensor (e.g., DHT11 or DS18B20): The temperature sensor monitors
the ambient temperature. An abnormal increase in temperature can be an indicator of a
potential fire, especially when detected alongside other signs like smoke or flames.
• Humidity Sensor (e.g., DHT11): The humidity sensor measures moisture levels in the
air. While it primarily provides supporting data, monitoring humidity can help reduce
false positives, as very low humidity in conjunction with high temperatures might
indicate a fire.
3. Embedded C Programming
The system's software is developed using Embedded C programming. The microcontroller is
programmed to read the sensor data, process it, and send the information to the cloud platform.
The software defines thresholds for each sensor, triggering alerts when these thresholds are
exceeded. It also manages the Wi-Fi connectivity to ensure seamless data transmission to the
cloud.
4. Cloud Platform (Blynk IoT)
The Blynk IoT platform is utilized for real-time data monitoring and alert notifications. It
serves as the interface between the IoT device (NODE MCU) and the end user. The sensor data
is transmitted to Blynk’s cloud servers, where it is processed and visualized on the user's
smartphone through the Blynk app. The platform enables users to:

44
• Monitor Real-Time Data: Users can view live sensor readings, including smoke
levels, flame detection status, temperature, and humidity, directly from their mobile
device.
• Receive Instant Alerts: The Blynk platform sends immediate notifications (SMS,
email, or app alerts) when any sensor reading exceeds the safe threshold. For instance,
if smoke is detected or the temperature rises rapidly, the user receives an alert, allowing
them to respond quickly.
5. Machine Learning Algorithms
To enhance the accuracy of the system and reduce the occurrence of false alarms, simple
machine learning algorithms can be implemented. These algorithms analyze patterns in sensor
data to distinguish between real fire hazards and non-threatening conditions like cooking smoke
or dust.
• Data Analysis: The machine learning model considers multiple sensor inputs
simultaneously, such as smoke levels, temperature, and flame detection status. For
example, high smoke levels combined with a sudden temperature rise may indicate a
real fire, whereas high smoke levels without a temperature increase might suggest a
false alarm.
• Pattern Recognition: Over time, the system learns from sensor data, improving its
ability to recognize typical patterns associated with false alarms. This adaptive feature
enhances the reliability of alerts, minimizing unnecessary notifications.
6. Power Supply and Rectifiers
The system requires a stable power supply to ensure uninterrupted operation. A rectifier is used
to convert the standard alternating current (AC) from power outlets to direct current (DC),
which is necessary for powering the microcontroller and sensors. This setup helps maintain the
system's reliability, even during minor power fluctuations.
Key Features and Advantages
1. Real-Time Monitoring and Alerts
One of the standout features of this IoT-based smoke detection system is its real-time
monitoring capability. Through the Blynk app, users can continuously track sensor data, such
as smoke concentration, flame presence, temperature, and humidity, from anywhere in the
world. This constant vigilance allows for immediate response to any abnormal readings.
The system's alert mechanism sends notifications directly to the user's mobile device, providing
an instant warning when potential fire hazards are detected. This prompt notification can help
prevent or mitigate fire damage by enabling users to take quick action, such as contacting
emergency services or manually triggering fire suppression systems.
2. Remote Accessibility
Unlike traditional smoke detectors that only sound a local alarm, this IoT-enabled system offers
remote accessibility. Users can monitor the status of their property in real-time through the
Blynk app, even when they are not physically present. This feature is particularly beneficial for
property owners who travel frequently or manage multiple locations.
3. Affordability and Ease of Installation

45
The components used in this system are relatively inexpensive and widely available, making it
an affordable solution for enhancing fire safety. The setup is straightforward, with plug-and-
play sensors and a user-friendly microcontroller. This ease of installation makes the system
accessible to a wide range of users, including homeowners, small businesses, and industrial
facilities.
4. Scalability and Customization
The IoT-based smoke detection system is highly scalable, allowing users to expand its coverage
by adding more sensors as needed. For larger spaces or multi-room buildings, additional smoke,
flame, and temperature sensors can be integrated into the network to ensure comprehensive
monitoring. The system can also be customized to fit specific requirements, such as integrating
with existing smart home devices or triggering automated responses like shutting off electrical
circuits or activating fire suppression sprinklers.
5. Enhanced Accuracy with Machine Learning
The incorporation of machine learning algorithms significantly reduces false alarms, which are
a common issue with traditional smoke detectors. By analyzing data from multiple sensors and
recognizing patterns associated with real fire incidents, the system can differentiate between
genuine threats and benign conditions like cooking smoke or steam. This enhancement
improves the reliability of the system, ensuring users take alerts seriously.
6. Energy Efficiency
The system is designed to be energy-efficient, consuming minimal power when idle and only
activating higher power-consuming components (like Wi-Fi transmission) when necessary.
This design reduces operational costs and extends the lifespan of the components, making it a
sustainable solution for long-term use.
7. Integration with Smart Home Systems
The system can be integrated with various smart home devices, enhancing its functionality and
user experience. For instance, when smoke or fire is detected, the system can automatically
trigger smart home actions, such as:
• Turning Off Electrical Appliances: Reducing the risk of electrical fires by cutting
power to appliances.
• Activating Sprinkler Systems: Mitigating fire damage by automatically turning on
water sprinklers.
• Sending Alerts to Emergency Services: Notifying local fire departments for rapid
response.
Conclusion
The IoT-based Smart Smoke Detection System represents a significant advancement in fire
safety technology, offering enhanced monitoring, real-time alerts, and the ability to respond
proactively to potential fire hazards. Its affordability, scalability, and integration with smart
home systems make it an appealing choice for both residential and commercial applications.
By leveraging the capabilities of the ESP8266 microcontroller and cloud-based platforms like
Blynk, this system provides a robust, reliable, and user-friendly solution for early fire detection,
potentially saving lives and reducing property damage.

46
9. REFERENCES

[1] A. Mahgoub, N. Tarrad, R. Elsherif, A. Al-Ali and L. Ismail, "IoT-Based Fire Alarm
System," 2019 Third World Conference on Smart Trends in Systems Security and
Sustainability (WorldS4), 201
[2] Sassani, B. A., Jamil, N., Villapol, M., Abbas Malik, M., & Tirumala, S. S. (2020). FireNot–
An IoT based Fire Alerting System: Design and Implementation. Journal of Ambient
Intelligence and Smart Environments, 12(6), 475- 489.
[3] Vijayalakshmi, S. R., & Muruganand, S. (2017). Internet of Things technology for fire
monitoring system. Int. Res. J. Eng. Technol, 4(6), 2140-2147.
[4] Alqourabah, H., Muneer, A., & Fati, S. M. (2021). A smart fire detection system using IoT
technology with an automatic water sprinkler. International Journal of Electrical & Computer
Engineering (2088-8708), 11(4).
[5] Sungheetha, A., & Sharma, R. (2020). Real time monitoring and fire detection using
internet of things and cloudbased drones. Journal of Soft Computing Paradigm (JSCP), 2(03),
168-174.
[6] Sharma, A., Singh, P. K., & Kumar, Y. (2020). An integrated fire detection system using
IoT and image processing technique for smart cities. Sustainable Cities and Society, 61,
102332.
[7] Saponara, S., Elhanashi, A., & Gagliardi, A. (2021). Real-time video fire/smoke detection
based on CNN in antifire surveillance systems. Journal of Real-Time Image Processing, 18,
889-900.
[8] Gupta, A., Srivastava, R., Gupta, H., & Kumar, B. (2020, November). IoT-based fall
detection monitoring and alarm system for elderly. In 2020 IEEE 7th Uttar Pradesh Section
International Conference on Electrical, Electronics and Computer Engineering (UPCON) (pp.
1-5). IEEE.
[9] Jumaa, N. K., Abdulkhaleq, Y. M., Nadhim, M. A., & Abbas, T. A. (2022). IoT-Based Gas
Leakage Detection and Alarming System using Blynk platforms. Iraqi J. Electr. Electron. Eng,
18, 64-70.
[10] Prabha, B. (2019, December). An IoT based efficient fire supervision monitoring and
alerting system. In 2019 Third International conference on I-SMAC (IoT in Social, Mobile,
Analytics and Cloud)(I-SMAC) (pp. 414-419). IEEE.
[11] Yadav, R., & Rani, P. (2020, November). Sensor based smart fire detection and fire alarm
system. In Proceedings of the International Conference on Advances in Chemical Engineering
(AdChE).
[12] Salman, A. D., Khalaf, O. I., & Abdulsahib, G. M. (2019). An adaptive intelligent alarm
system for wireless sensor network. Indonesian Journal of Electrical Engineering and
Computer Science, 15(1), 142-147.
[13] Saponara, S., Elhanashi, A., & Gagliardi, A. (2021). Real-time video fire/smoke detection
based on CNN in antifire surveillance systems. Journal of Real-Time Image Processing, 18,
889-900.

47
[14] Jadon, A., Omama, M., Varshney, A., Ansari, M. S., & Sharma, R. (2019). FireNet: a
specialized lightweight fire & smoke detection model for real-time IoT applications. arXiv
preprint arXiv:1905.11922.
[15] Valikhujaev, Y., Abdusalomov, A., & Cho, Y. I. (2020). Automatic fire and smoke
detection method for surveillance systems based on dilated CNNs. Atmosphere, 11(11), 1241.

48
APPENDIX A -SAMPLE CODE
#define BLYNK_TEMPLATE_ID "TMPL3A5y0qsm2"
#define BLYNK_TEMPLATE_NAME "smoke detection system"
#define BLYNK_AUTH_TOKEN "quT0PQfFPTyvYvFxH_AF834pX3k69Gow"

#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels


#define SCREEN_HEIGHT 64 // OLED display height, in pixels

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); // Initialize


OLED display

char auth[] = BLYNK_AUTH_TOKEN;


char ssid[] = "Sus"; // WiFi name
char pass[] = "shiven1234"; // WiFi password

BlynkTimer timer;

int GasSensor = A0; // Gas sensor input pin


#define Buzzer D6 // Buzzer pin

int sensorThreshold = 900; // Adjusted threshold for gas detection


bool buzzerActive = false; // To track buzzer status

// Blynk virtual pin for buzzer control


BLYNK_WRITE(V1) {
int value = param.asInt(); // Get value from Blynk app (0 or 1)
if (value == 0) {
stopBuzzer(); // Stop the buzzer if the button is pressed
}
}

// Function to stop the buzzer


void stopBuzzer() {
buzzerActive = false;
digitalWrite(Buzzer, LOW); // Turn off the buzzer
Serial.println("Buzzer Stopped");

49
}

// Function to read sensor value and update status


void sendSensor() {
int gasValue = analogRead(GasSensor);
Blynk.virtualWrite(V0, gasValue); // Send gas value to the Blynk app
Serial.print("Gas Value: ");
Serial.println(gasValue);

// Display real-time gas value on OLED


display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.print("Gas Value: ");
display.print(gasValue);

display.setCursor(0, 10);
display.print("Threshold: ");
display.print(sensorThreshold);

// Check gas level against the threshold


if (gasValue < sensorThreshold) {
// Normal Condition
display.setCursor(0, 20);
display.print("Status: Normal");
if (!buzzerActive) {
digitalWrite(Buzzer, LOW); // Ensure buzzer is off
}
Serial.println("Gas Normal");
} else {
// High Gas Level
display.setCursor(0, 20);
display.print("Status: HIGH ALERT");
Serial.println("Gas is High");

// Activate the buzzer for 3 seconds if not already active


if (!buzzerActive) {
buzzerActive = true;
digitalWrite(Buzzer, HIGH); // Buzzer ON
Serial.println("Buzzer Activated for 3 seconds");
Blynk.logEvent("gas_alert", "Gas is High");

50
timer.setTimeout(3000L, stopBuzzer); // Schedule buzzer to stop after 3 seconds
}
}

display.display(); // Update the display


}

void setup() {
Serial.begin(115200);

// Set Pin Modes


pinMode(GasSensor, INPUT);
pinMode(Buzzer, OUTPUT);

// Initialize Blynk
Blynk.begin(auth, ssid, pass);

// Set Timer Interval for Sensor Readings


timer.setInterval(1000L, sendSensor);

// Initialize OLED Display


if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
while (true); // Stop if initialization fails
}

display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(20, 20);
display.print("Calibrating...");
display.display();
delay(2000);
display.clearDisplay();
}

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

51
52

You might also like