0% found this document useful (0 votes)
2 views20 pages

Project 1 final FFFFFFFFFFFFFFFFFFFFFFFF

The document outlines a project focused on designing a fire alarm system using Arduino, specifically incorporating MQ2 and flame sensors for smoke and fire detection. The system provides visual and audible alerts and is suitable for small-scale applications like homes and offices. The project includes circuit design, programming, and final assembly, demonstrating practical applications of control and automation principles.

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)
2 views20 pages

Project 1 final FFFFFFFFFFFFFFFFFFFFFFFF

The document outlines a project focused on designing a fire alarm system using Arduino, specifically incorporating MQ2 and flame sensors for smoke and fire detection. The system provides visual and audible alerts and is suitable for small-scale applications like homes and offices. The project includes circuit design, programming, and final assembly, demonstrating practical applications of control and automation principles.

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
You are on page 1/ 20

HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY

PROJECT I

DESIGNING A FIRE ALARM SYSTEM BASED ON ARDUINO


DEVICE

NGUYỄN MINH NGHĨA


[email protected]

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


[email protected]

MAJOR: CONTROL & AUTOMATION

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

Bộ môn: 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. Flame sensor................................................................................- 1 -
1.2.4. Both are detected.........................................................................- 1 -
1.3. Background theory...............................................................................- 2 -
1.3.1. Arduino UNO R3.............................................................................- 2 -
1.3.2. MQ2 smoke sensor..........................................................................- 3 -
CHAPTER 2: SCHEMATIC CIRCUIT DESIGN AND CODE.................- 5 -
2.1. Schematic design on proteus...................................................................- 5 -
2.2. Code injected into Arduino R3...............................................................- 5 -
2.3. Simulation Result....................................................................................- 8 -
CHAPTER 3: FINAL PRODUCTION........................................................- 10 -
3.1. Circuit showcase...................................................................................- 10 -
3.2. Different case scenario results..............................................................- 11 -
3.2.1. Idle state.........................................................................................- 11 -
3.2.2. Only smoke detected..........................................................................- 12 -
3.2.3. Only flame detected...........................................................................- 12 -
3.2.4. Both are detected................................................................................- 13 -
CHAPTER 4: CONCLUSION........................................................................- 14 -
4.1. Summary...............................................................................................- 14 -
4.2. Suggetions for future work...................................................................- 14 -
REFERENCES...............................................................................................- 15 -
ACKNOWLEDGEMENT
We sincerely thank my 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 me refine my work but also trained me 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, a 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. 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 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 it have 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 user’s 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. 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
1.3. Background theory
1.3.1. Arduino UNO R3
The Arduino UNO R3 is a microcontroller board based on the
ATmega328P chip. It is 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
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.

2
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.

1.3.2. MQ2 smoke sensor


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.

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.

3
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.

4
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);
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
5
pinMode(buzzer, OUTPUT);
Serial.begin(9600); // Start Serial Monitor
}

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

Serial.print("Gas Sensor: ");


Serial.print(gasDetected);
Serial.print(" | Flame Sensor: ");
Serial.println(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);

if (!digitalRead(Flame)) {
digitalWrite(redLed, LOW);

6
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


}

7
2.3. Simulation Result

Fig 2.1. Idle state

Fig 2.2. Flame detection on only

8
Fig 2.3. Smoke detection on only

Fig 2.4. Both sensors are on

9
CHAPTER 3: FINAL PRODUCTION
3.1. Circuit showcase

Fig 3.1.1 Whole circuit

Fig 3.1.2 Polished product from sideway

10
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

11
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

12
3.2.4. Both are detected

Fig 3.2.4. Both elements are detected


Drive link for the video: https://drive.google.com/drive/folders/1of-
kc6HemSi4T4WJ6yjO_dAbv4rLIWMr?usp=sharing

13
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.

14
REFERENCES
Getting started with arduino:
https://docs.arduino.cc/learn/starting-guide/getting-started-arduino/
Arduino MQ R3 component detail:
https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7810-
Automotive-Microcontrollers-ATmega328P_Datasheet.pdf
MQ2 semiconductor sensor for combustable gas:
https://www.pololu.com/file/0j309/mq2.pdf

15

You might also like