Fire Detection Sensor System Using 8051 Microcontroller
Fire Detection Sensor System Using 8051 Microcontroller
microcontroller
Embedded C Programming
(BECE320E)
Slot – G2
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.
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.
sbit rs = P3^7;
sbit rw = P3^6;
sbit en = P3^5;
// LCD functions
int a, b;
P2 = A;
rs = 0;
rw = 0;
en = 1;
delay(1000);
en = 0;
P2 = i;
rs = 1;
rw = 0;
en = 1;
delay(1000);
en = 0;
int k;
lcddat(q[k]);
delay(10000);
void main() {
lcdcmd(0x38);
lcdcmd(0x01);
while (1) {
if (flameSensor == 1 || gasSensor == 1) {
} else {
➢ 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.
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;
This function implements a delay based on nested loops for a specified duration.
This function sends a command to the LCD module using the control pins defined earlier.
These lines define the pins for the flame sensor, gas sensor, and buzzer.
void main() {
// 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.
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.