0% found this document useful (0 votes)
15 views25 pages

Proj1 Continued

The project involves designing a fire alarm system using Arduino, focusing on early smoke and flame detection for safety. It includes components like the MQ2 gas sensor and KY-026 flame sensor, with a successful implementation that alerts users through visual and audible signals. The final model is practical for small-scale use, and future improvements could integrate IoT for remote monitoring.

Uploaded by

Tất Thắng
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views25 pages

Proj1 Continued

The project involves designing a fire alarm system using Arduino, focusing on early smoke and flame detection for safety. It includes components like the MQ2 gas sensor and KY-026 flame sensor, with a successful implementation that alerts users through visual and audible signals. The final model is practical for small-scale use, and future improvements could integrate IoT for remote monitoring.

Uploaded by

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

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

PROJECT I

DESIGNING A FIRE ALARM SYSTEM BASED ON ARDUINO


DEVICE

NGUYỄN MINH NGHĨA


nghia.nm222795@[Link]

NGUYỄN XUÂN TẤT THẮNG


thang.nxt222757@[Link]

MAJOR: CONTROL & AUTOMATION

Supervisor: Associate Prof. Phạm Văn Tuynh

Subject: Project I
School: Electronic and electric

Hà Nội, April 2025


Contents
CHAPTER 1: INTRODUCTION...................................................................- 1 -
1.1. Component we used............................................................................- 1 -
1.2. Our idea on designing the circuit......................................................- 1 -
1.2.1. General circuit..........................................................................- 1 -
1.2.2. MQ2 sensor...............................................................................- 1 -
1.2.3. KY-026 Flame sensor...............................................................- 1 -
1.2.4. Both are detected......................................................................- 1 -
CHAPTER 2: SCHEMATIC CIRCUIT DESIGN AND CODE.................- 9 -
2.1. Schematic design on proteus...................................................................- 9 -
2.2. Code injected into Arduino R3...............................................................- 9 -
2.3. Simulation Result..................................................................................- 12 -
CHAPTER 3: FINAL PRODUCTION........................................................- 14 -
3.1. Circuit showcase...................................................................................- 14 -
3.2. Different case scenario results..............................................................- 15 -
3.2.1. Idle state.........................................................................................- 15 -
3.2.2. Only smoke detected..........................................................................- 16 -
3.2.3. Only flame detected...........................................................................- 16 -
3.2.4. Both are detected................................................................................- 17 -
CHAPTER 4: CONCLUSION........................................................................- 19 -
4.1. Summary...............................................................................................- 19 -
4.2. Suggetions for future work...................................................................- 19 -
REFERENCES...............................................................................................- 20 -
ACKNOWLEDGEMENT

We sincerely thank our instructor for dedicating time, effort, and expertise
to guide us throughout this project. He has devoted his time, effort, and
detailed feedback not only helped us refine our work but also trained us to
think more clearly and logically. We especially appreciate his patience
during times when we felt uncertain or lacked confidence. Our discussions
were valuable learning experiences, both technically and professionally.
Once again, thank you for your unwavering support and guidance.
ABSTRACT

This project focused on developing a simple fire alarm system capable of


early smoke and flame detection to ensure human safety. It was completed
over six weeks, covering idea development, circuit design in Proteus,
programming smoke and flame sensors (MQ2 and flame sensor) using
Arduino IDE, and assembling the final model. The system uses Arduino
Uno R3, MQ2 gas sensor, KY 026 flame sensor, LEDs, and a buzzer to
provide visual and audible alerts. The model successfully met the initial
goals, detecting smoke, fire, or both, and issuing alerts automatically, as
well as fixing initial problem. It's practical and suitable for small-scale use,
such as in homes or offices. Through this project, students gained hands-on
experience in circuit design, C/C++ programming, and applying knowledge
to create a useful prototype.
CHAPTER 1: INTRODUCTION

1.1. Component we used


- Arduino UNO R3
- Smoke detector MQ2
- Flame sensor KY- 026
- LEDs
- Resistors
- Buzzer
- Wires and breadboard, 9V DC battery.
1.2. Our idea on designing the circuit
1.2.1. General circuit
We want to design a circuit that has two main states: IDLE and ACTIVE.
When a sensor or more than one sensor is detected, the buzzer and LED
will have different pulses, which will hint the user which sensor have gone
off.
The IDLE state is silent and have green LED on, red LED off. ACTIVE
state is when green LED is off, red LED is on, buzzer pulses depend on
which condition is met.
1.2.2. MQ2 sensor
When only smoke is detected, the buzzer will buzz rapidly, and the red
LED is on, buzzer pulses rapidly ( ~100ms between pulses and 500ms
deadzone when no smoke is detected). If nothing detected, the circuit goes
back to IDLE state
1.2.3. KY 026 Flame sensor
When only flame is detected, red led is on, buzzer will buzz at medium
speed (~ 350ms delay, 50ms pulse and 500ms deadzone when no flame is
detected). If nothing is detected, the circuit goes back to IDLE state.
1.2.4. Both are detected
When both are detected, red led is on, buzzer will buzz at slow speed with
longer pulse (~500ms and 500ms pulse, 500ms deadzone). If nothing is
detected, the circuit goes back to IDLE state.

1
2.1. Background theory
2.1.1. Arduino UNO R3

The Arduino UNO R3 is a microcontroller board based on the


ATmega328P chip. It is a part of the Arduino platform, which is designed
to simplify the process of working with microcontrollers through open-
source hardware and software.
Microcontroller: ATmega328P
Operating Voltage: 5V
Input Voltage (recommended): 7–12V
Digital I/O Pins: 14 (6 can be used as PWM outputs)
Analog Input Pins: 6
Clock Speed: 16 MHz
Flash Memory: 32 KB (0.5 KB used by bootloader)
SRAM: 2 KB
EEPROM: 1 KB

2
USB Connection: Standard B-type connector for programming and power

Theoretical Foundation:
Microcontroller Basics:
The ATmega328P is an 8-bit AVR microcontroller.
It executes instructions sequentially and can interact with sensors,
actuators, and other hardware.
It uses memory (Flash, SRAM, EEPROM) to store programs and data.

Embedded System Concepts:


The Arduino UNO R3 is an embedded system—an integration of hardware
and software to perform dedicated functions.
It operates in real-time and is used in applications ranging from robotics to
home automation.

Programming and Development:


Programs (called sketches) are written in a simplified version of C/C++
using the Arduino IDE.
The Arduino bootloader allows uploading code via USB without needing
an external programmer.

Open-Source Philosophy:
Both the hardware schematics and software tools are open-source.
This promotes rapid prototyping, learning, and community collaboration.
Interfacing and Communication:
Supports communication protocols like UART (Serial), I2C, and SPI.
It can interface with various modules like Bluetooth, Wi-Fi, sensors, and
displays.

2.1.2. MQ2 smoke sensor

3
The MQ2 sensor is a gas sensor used to detect a variety of gases, including
LPG, propane, methane, hydrogen, smoke, and carbon monoxide. It is
commonly used in gas leakage detection systems in consumer and
industrial applications.

Important Features:
Detectable Gases: LPG, butane, methane, alcohol, hydrogen, smoke, CO
Operating Voltage: 5V
Analog Output: Voltage varies with gas concentration
Digital Output: High/low signal based on threshold (with onboard
comparator)
Preheat Time: 20 seconds (sensor needs warming up)

Theoretical Foundation:
Gas-Sensitive Material:
The sensor’s core is made of SnO₂ (tin dioxide), a semiconductor whose
conductivity increases in the presence of combustible gases.
In clean air, SnO₂ has low conductivity. When target gases are present,
their interaction with the surface increases conductivity.

4
Heater Element:
A built-in heater coil maintains the sensor at an optimal operating
temperature (~200–400°C), enabling proper gas adsorption and reaction.

Resistance Variation:
The sensor’s output is based on the change in resistance (Rs) due to gas
exposure, relative to its resistance in clean air (Ro).
The ratio Rs/Ro can be used to estimate gas concentration using a
logarithmic sensitivity graph provided in the datasheet.

Signal Output:
The MQ2 provides both analog (variable voltage) and digital (high/low)
outputs.
The analog output can be read by a microcontroller (e.g., Arduino) and
processed to estimate gas concentration.
The digital output is controlled by an onboard comparator and can be tuned
with a potentiometer.

Sensitivity and Calibration:


The sensor must be calibrated in a known concentration of target gas to
establish accurate readings.
Sensitivity depends on temperature, humidity, and gas type.

2.1.3. KY-026 Flame Sensor

5
The KY-026 Flame Sensor is an infrared (IR) sensor module designed to
detect flame or light sources emitting IR radiation in the wavelength range
of 760–1100 nm. It is commonly used in fire detection systems, firefighting
robots, and safety alarms.

Important Features:
Detectable Source: Flame or fire (infrared light in 760–1100 nm range)

Operating Voltage: 3.3V – 5V

Analog Output: Voltage varies based on flame intensity

Digital Output: High/Low signal based on adjustable threshold (with


onboard LM393 comparator)

Detection Distance: Typically up to 100 cm (depends on flame size and


sensitivity setting)
6
Adjustable Sensitivity: Via onboard potentiometer

Theoretical Foundation:
IR Flame Detection Principle:
Flames emit infrared (IR) radiation, especially in the range of 760–1100
nm.

The KY-026 uses a high-sensitivity IR photodiode or phototransistor to


detect these wavelengths.

The intensity of IR radiation detected is converted into electrical signals,


which can be processed digitally or read as analog voltages.

Comparator Circuit (LM393):


The module features a voltage comparator (LM393) that compares the
analog voltage from the IR detector to a reference level set by the
potentiometer.

The digital output (D0) switches LOW when a flame is detected (IR
intensity above threshold), and HIGH otherwise.

Signal Output:
Analog Output (A0):
Provides a voltage proportional to the detected IR intensity. This can be
used to estimate proximity or flame intensity.

Digital Output (D0):


Outputs a logic LOW (0V) when a flame is detected, and HIGH (5V or
3.3V) otherwise.
The sensitivity can be adjusted using the onboard potentiometer.

Sensitivity and Usage:


The sensor is sensitive to IR radiation, so it may give false readings in
environments with strong IR sources (e.g., sunlight or incandescent bulbs).

7
Best results are obtained in indoor environments with minimal ambient IR
interference.

The detection angle is narrow (~60 degrees), so the sensor must be aimed
directly at the flame.

No calibration is typically required, but the sensitivity should be tuned


manually via the potentiometer for optimal performance.

8
CHAPTER 2: SCHEMATIC CIRCUIT DESIGN AND CODE

2.1. Schematic design on proteus

Fig 1. Fire alarm schematic circuit


2.2. Code injected into Arduino R3
We used Arduino IDE to code and compile into .hex file so it’s compatible
in proteus.
Here is the code we used in C:
int Gas = 9;
int Flame = 10;
int redLed = 7;
int greenLed = 6;
int buzzer = 8;

bool prevFlameState = false ;


previous flame state

void setup() {
pinMode(Gas, INPUT);
pinMode(Flame, INPUT);

9
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
pinMode(buzzer, OUTPUT);
[Link](9600); // Start Serial Monitor
}

void loop() {
bool gasDetected = digitalRead(Gas);
bool flameDetected = digitalRead(Flame);

[Link]("Gas Sensor: ");


[Link](gasDetected);
[Link](" | Flame Sensor: ");
[Link](flameDetected);

if (gasDetected && flameDetected) {


// Both gas and flame detected → Intense Alert
digitalWrite(redLed, HIGH);
digitalWrite(greenLed, LOW);
for (int i = 0; i < 3; i++) { // Fast buzzer sound
tone(buzzer, 1500, 300);
delay(300);
}
} else if (flameDetected) {
// Flame detected → Blinking Red LED & Continuous Buzzer
digitalWrite(greenLed, LOW);

if (!prevFlameState) {
prevFlameState = true;

for (int i = 0; i < 5; i++) {


digitalWrite(redLed, HIGH);
tone(buzzer, 2000, 200);
delay(200);

10
if (!digitalRead(Flame)) {
digitalWrite(redLed, LOW);
noTone(buzzer);
prevFlameState = false;
return;
}

digitalWrite(redLed, LOW);
tone(buzzer, 2000, 200);
delay(200);
}
}
} else if (gasDetected) {
// Gas detected → Solid Red LED & Short Buzzer
digitalWrite(redLed, HIGH);
digitalWrite(greenLed, LOW);
tone(buzzer, 1000, 500);
delay(500);
} else {
// No gas, no flame → Green LED stays on, everything else off
digitalWrite(greenLed, HIGH);
digitalWrite(redLed, LOW);
noTone(buzzer);

// Reset flame state when no flame is detected


prevFlameState = false;
}

delay(500); // Stabilization delay


}

11
2.3. Simulation Result

Fig 2.1. Idle state

Fig 2.2. Flame detection on only

12
Fig 2.3. Smoke detection on only

Fig 2.4. Both sensors are on

13
CHAPTER 3: FINAL PRODUCTION

3.1. Circuit showcase

Fig 3.1.1 Whole circuit

Fig 3.1.2 Polished product from sideway

14
Fig 3.1.3 Top view of the polished product

3.2. Different case scenario results

3.2.1. Idle state

Fig 3.2.1 Idle state

15
3.2.2. Only smoke detected

Fig 3.2.2. Only smoke detected


3.2.3. Only flame detected

Fig 3.2.3. Only flame detected

16
3.2.4. Both are detected

Fig 3.2.4. Both elements are detected

Drive link for the video: [Link]


kc6HemSi4T4WJ6yjO_dAbv4rLIWMr?usp=sharing

3.3 Improving the system

While testing the polished version of system , a problem emerged:


The flame sensor became less effective, with 1-2 second of delay
To solve this problem, a conical-shaped hole was carved into the external
box

17
Fig 3.3.1. The fixed polished version

Result: the problem was fixed successfully, with the flame sensor works as
intended

18
CHAPTER 4: CONCLUSION
4.1. Summary
The final model met all the initial requirements: it could automatically
detect smoke, fire, or both, and issue warnings accordingly. It is practical
and easy to implement in small environments like homes or offices.
4.2. Suggetions for future work
Future improvements include integrating it with the Internet of Everything
(IoE) for remote monitoring and control.

19
REFERENCES
Getting started with arduino:
[Link]
Arduino MQ R3 component detail:
[Link]
Automotive-Microcontrollers-ATmega328P_Datasheet.pdf
MQ2 semiconductor sensor for combustable gas:
[Link]
MKY-206 Inf

20

You might also like