0% found this document useful (0 votes)
297 views

Fire Detection Sensor System Using 8051 Microcontroller

fire Detection system

Uploaded by

Swaraj Patel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
297 views

Fire Detection Sensor System Using 8051 Microcontroller

fire Detection system

Uploaded by

Swaraj Patel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Fire Detection Sensor System using 8051

microcontroller

Embedded C Programming
(BECE320E)

Slot – G2

Submitted to: Dr. Angeline Ezhilarasi G


Submitted by:
Muskan Nayan Singh (21BEE1161)
Ayushi (21BEE1160)
Sumedha Das (21BEE1089)
Swaraj Patel (21BEE1067)
Abstract:

The project is a fire and gas detection system implemented using the AT89C51
microcontroller, flame sensor, MQ-9 gas sensor, and a buzzer. The system continuously
monitors the environment for the presence of fire or gas. When either the flame sensor or gas
sensor detects an anomaly, indicating the presence of fire or gas leakage, the buzzer is
activated to provide an audible alert. The buzzer sounds for 1 second to alert users of the
potential hazard. The system operates in a loop, constantly checking the sensor inputs and
responding accordingly. This project offers a simple yet effective solution for detecting fire
and gas issues in an environment, providing a basic level of safety and alerting users to
potential dangers.
Introduction:
Fire and gas detection systems are
essential for ensuring safety in various
environments, including homes,
workplaces, and industrial settings. This
project focuses on the development of a
fire and gas detection system using the
AT89C51 microcontroller, flame sensor,
MQ-9 gas sensor, and a buzzer. The
system is designed to continuously
monitor the surroundings for the presence
of fire or gas leakage, providing an
immediate alert in case of detection.
By leveraging the capabilities of the
AT89C51 microcontroller and
integrating sensors for fire and gas 3. MQ-9 Gas Sensor: The MQ-9 gas
detection, this sensor is used to detect the presence of
project aims to create a cost-effective and combustible gases such as methane,
efficient solution for enhancing safety propane, and carbon monoxide. It provides
measures. The system's ability to detect an analog output based on the gas
potential hazards such as fire and gas leaks concentration in the environment.
and promptly alert users through an
audible alarm can help prevent accidents,
minimize damage, and potentially save
lives.
Additionally, we explored the significance
of such systems in ensuring safety in
various environments and the potential
applications of this project in real-world
scenarios.

Components:
1. AT89C51 Microcontroller: The
AT89C51 is a popular 8-bit microcontroller
with a built-in UART, timers/counters, and
programmable I/O ports. It serves as the
main control unit for the system.

2. Flame Sensor: The flame sensor is used


to detect the presence of flames or fire. It
can detect infrared light emitted by flames,
triggering an alarm when a fire is detected.
4. Buzzer: The buzzer is an
electromechanical component that
produces an audible alarm when activated.
In this project, the buzzer is used to
provide an alert when fire or gas is
detected.

Specifications:
5. Resistors and Capacitors: These passive
components are used for signal
conditioning, voltage regulation, and 1. The AT89C51 is based on the 8051
filtering purposes in the circuit. architecture, featuring a Harvard
architecture with separate program
and data memory spaces. It has a
16-bit address bus and an 8-bit data
bus. The microcontroller operates
at a maximum frequency of 33
MHz. It executes most instructions
in one or two machine cycles,
making it suitable for applications
that require high-speed processing.
The AT89C51 has 8 KB of on-chip
Flash memory for program storage.
It also includes 256 bytes of RAM
for data storage and 128 bytes of
6. Connecting Wires and Breadboard:
EEPROM for non-volatile data
These are used to establish connections
storage. The microcontroller has
between the components and create the
four 8-bit I/O ports (P0, P1, P2, P3)
circuit on a breadboard for prototyping and
that can be used for interfacing
testing purposes.
with external devices. These ports
can be configured as input or the sensing element to an optimal
output ports based on the operating temperature. This heating
application requirements. The element ensures fast response times
microcontroller supports serial and accurate detection of gas
communication through a full- concentrations. The MQ-9 gas
duplex UART (Universal sensor is commonly used in gas
Asynchronous Receiver detection systems, safety alarms,
Transmitter). This feature enables industrial monitoring equipment,
communication with external and environmental monitoring
devices such as sensors, displays, devices. It plays a crucial role in
and other microcontrollers. ensuring safety by detecting the
Overall, the AT89C51 presence of potentially hazardous
microcontroller is a versatile and gases in the surroundings.
reliable choice for embedded 3. The flame sensor operates based on
systems development, offering a the principle of detecting infrared
balance of performance, features, radiation emitted by flames. When
and ease of programming. Its rich a flame is present, it emits IR
set of peripherals and robust radiation that is detected by the
architecture make it suitable for a sensor, triggering a response.
wide range of applications, Flame sensors typically have a
including industrial control, detection range of a few meters,
automation, IoT devices, and more. depending on the sensitivity of the
2. The MQ-9 gas sensor operates sensor and the intensity of the
based on the principle of gas flame. They can detect flames in
detection through a chemical various environments, including
reaction. It contains a tin dioxide homes, industrial settings, and
(SnO2) semiconductor sensing automotive applications. Flame
element that changes its electrical sensors are highly sensitive to the
conductivity in the presence of specific wavelengths of IR
combustible gases. The MQ-9 radiation emitted by flames. They
sensor is highly sensitive to a range are designed to distinguish between
of combustible gases, making it the IR radiation from flames and
suitable for detecting gas leaks in background IR radiation to
various environments. It can detect minimize false alarms. Flame
concentrations of gases in the range sensors have a fast response time,
of tens to hundreds of parts per allowing them to quickly detect the
million (ppm). The MQ-9 sensor presence of flames and trigger an
provides an analog output voltage alarm or alert system. This rapid
that varies with the concentration response time is crucial for
of the target gas in the ensuring timely action in the event
environment. The sensor's of a fire. Flame sensors are
resistance changes based on the gas commonly used in fire detection
concentration, resulting in a and alarm systems, industrial
corresponding voltage output. The furnaces, gas appliances, and flame
MQ-9 sensor includes an integrated monitoring applications. They play
heating element that is used to heat a critical role in enhancing safety
by detecting fires at an early stage 3. MQ-9 Gas Sensor: The MQ-9 gas
and initiating timely responses to sensor detects the presence of certain gases
prevent damage and injuries. such as carbon monoxide. It also has an
Overall, the flame sensor is a analog output that can be connected to an
valuable component in fire analog input pin of the 8051
detection systems, providing microcontroller.
reliable and accurate detection of
flames to ensure prompt action in
case of fire emergencies. Its 4. Buzzer: The buzzer is an output device
sensitivity to IR radiation emitted that can be used to provide an audible alert
by flames makes it an essential tool when a fire or gas leak is detected.
for enhancing safety and mitigating Connect the buzzer to a digital output pin
the risks associated with fires. of the 8051 microcontroller.

Methodology: Here is a simplified example of how we


can connect these components:
To draw the connections of a fire sensing
system using an 8051 microcontroller, a
flame sensor, an MQ-9 gas sensor, and a
➢ Connect the analog output of the
buzzer, we will need to connect the
flame sensor to an analog input pin
components in a way that allows the
of the 8051 microcontroller.
microcontroller to read sensor data and
➢ Connect the analog output of the
trigger the buzzer based on the sensor
MQ-9 gas sensor to another analog
inputs. Here is a general guide on how we
input pin of the 8051
can connect these components:
microcontroller.
➢ Connect the buzzer to a digital
output pin of the 8051
1. 8051 Microcontroller: The 8051 microcontroller.
microcontroller will be the central
processing unit that reads sensor data and
controls the buzzer. It will have
Now, we need to write a program for the
input/output pins that you can use to
8051 microcontroller that reads sensor
connect to other components.
data, processes it to detect fire or gas leaks,
and triggers the buzzer accordingly.

2. Flame Sensor: In the flame sensor we


use an analog output that indicates the
It is important to keep in mind the proper
presence of a flame. We can connect the
connections to be given while designing
flame sensor output to an analog input pin
the circuit. We need to identify the slots in
of the 8051 microcontroller to read the
the cables for the given pin we need to
flame sensor data. We need to be very
connect with the sensors and buzzer and
careful in providing the right pin number
then provide the write data in the code to
to the code which is being connected.
be loaded in the microcontroller.
Pin Connections of the cable:

Real time Circuit Layout:


Code:
#include <reg51.h>

// LCD control pins

sbit rs = P3^7;

sbit rw = P3^6;

sbit en = P3^5;

// LCD functions

void lcdcmd(unsigned char);

void lcddat(unsigned char);

void lcddisplay(unsigned char *);

// LCD delay function

void delay(unsigned int j) {

int a, b;

for (a = 0; a < j; a++) {

for (b = 0; b < 10; b++);

// LCD commands functions

void lcdcmd(unsigned char A) {

P2 = A;

rs = 0;

rw = 0;

en = 1;

delay(1000);

en = 0;

// LCD data function

void lcddat(unsigned char i) {

P2 = i;

rs = 1;

rw = 0;
en = 1;

delay(1000);

en = 0;

// LCD display characters function

void lcddisplay(unsigned char *q) {

int k;

for (k = 0; q[k] != '\0'; k++) {

lcddat(q[k]);

delay(10000);

sbit flameSensor = P1^1;

sbit gasSensor = P1^3;

sbit buzzer = P1^2;

void main() {

lcdcmd(0x0F); // LCD initialization

lcdcmd(0x38);

lcdcmd(0x01);

while (1) {

if (flameSensor == 1 || gasSensor == 1) {

lcdcmd(0x01); // Clear LCD

lcdcmd(0x80); // Move cursor to the beginning of the first line

lcddisplay("FIRE OR GAS DETECTED");

buzzer = 1; // Turn on the buzzer

delay(1000); // Delay for 1 second

buzzer = 0; // Turn off the buzzer

delay(1000); // Delay for 1 second

} else {

lcdcmd(0x01); // Clear LCD

lcdcmd(0x80); // Move cursor to the beginning of the first line

lcddisplay("NO FIRE OR GAS");


buzzer = 0; // Make sure the buzzer is off

➢ The program initializes the LCD and then enters an infinite loop to continuously
monitor the flame and gas sensors.
➢ If either sensor detects a flame or gas, the program displays the corresponding
message on the LCD and activates the buzzer for 1 second.
➢ If no flame or gas is detected, the program displays a message indicating no fire or
gas on the LCD and turns off the buzzer.

This code is a simple program written in C language for a microcontroller (8051 family) to
detect fire or gas using sensors and display the status on an LCD screen. Let's break down the
code and explain it thoroughly:

#include <reg51.h>

This line includes the header file `reg51.h`, which contains definitions specific to the 8051
microcontroller family.

sbit rs = P3^7;

sbit rw = P3^6;

sbit en = P3^5;

These lines define the control pins for interfacing with the LCD module. `rs` is the register
select pin, `rw` is the read/write pin, and `en` is the enable pin.

void lcdcmd(unsigned char);

void lcddat(unsigned char);

void lcddisplay(unsigned char *);

These lines declare the function prototypes for sending commands (`lcdcmd`), sending data
(`lcddat`), and displaying a string on the LCD (`lcddisplay`).
void delay(unsigned int j) {

int a, b;

for (a = 0; a < j; a++) {

for (b = 0; b < 10; b++);

This function implements a delay based on nested loops for a specified duration.

void lcdcmd(unsigned char A) {

// Implementation of sending command to the LCD

This function sends a command to the LCD module using the control pins defined earlier.

void lcddat(unsigned char i) {

// Implementation of sending data to the LCD

This function sends data to the LCD module for display.

void lcddisplay(unsigned char *q) {

// Implementation of displaying characters on the LCD

This function displays a string on the LCD by sending individual characters.

sbit flameSensor = P1^1;

sbit gasSensor = P1^3;

sbit buzzer = P1^2;

These lines define the pins for the flame sensor, gas sensor, and buzzer.
void main() {

// Initialization of the LCD

// Main loop to check for flame or gas detection and update the LCD and buzzer
status

The `main()` function initializes the LCD and contains the main logic to continuously
monitor the sensors for flame or gas detection and update the LCD display and buzzer
accordingly.

Real – Time Applications: be able to notice if there’s any


leakage. Early detection can
prompt quick responses to mitigate
risks.
1. Home Safety Systems:
Implementing this project in home
safety systems can help detect fires
or gas leaks in residential 4. Hospitals and Healthcare
buildings. The system can provide Facilities: Fire and gas detection
early warnings to residents, systems are essential in healthcare
enabling them to take prompt facilities to ensure the safety of
action and evacuate if necessary. patients, staff, and visitors. Early
detection can prevent disruptions to
critical services and protect
vulnerable individuals.
2. Industrial Safety: In industrial
settings, such a system can be used
5. Prevention of Forest Fires: This
to monitor for potential fire hazards
project can be of greater help in
or gas leaks in factories,
avoiding the cases of forest fires.
warehouses, and manufacturing
We can set several modules of this
plants. Early detection can prevent
system in various locations in the
accidents and ensure the safety of
forests and protected lands and also
workers and assets.
connect an automated sprinkler
system and notification sending
unit to it. Implementing this idea
will make this project a greater
3. Gas Stations: Implementing gas
help in preventing the spread of
detection systems at gas stations
forest fires.
can help monitor for gas leaks and
prevent potential explosions or
accidents. Also, if we include
sensors capable of sensing other
flammable gases then also, we will
Conclusion:

The idea of fire sensing and detecting system was implemented using a 8051 microcontroller,
flame sensor, MQ-9 gas sensor, buzzer and other electronic components. We aimed to create
a system which is versatile to detect several factors leading to fire hazards. We try to include
multiple sensors to observe flames, any leakage of gases, presence of after combustion gases
in the environment. Also, we included several alerting measures such as an LCD display and
buzzer to aware the people of any incident happening in real time.

You might also like