Project 1 final FFFFFFFFFFFFFFFFFFFFFFFF
Project 1 final FFFFFFFFFFFFFFFFFFFFFFFF
PROJECT I
Bộ môn: Project I
School: Electronic and electric
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.
2
Open-Source Philosophy:
Both the hardware schematics and software tools are open-source.
This promotes rapid prototyping, learning, and community collaboration.
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.
4
CHAPTER 2: SCHEMATIC CIRCUIT DESIGN AND CODE
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);
if (!prevFlameState) {
prevFlameState = true;
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);
7
2.3. Simulation Result
8
Fig 2.3. Smoke detection on only
9
CHAPTER 3: FINAL PRODUCTION
3.1. Circuit showcase
10
Fig 3.1.3 Top view of the polished product
3.2. Different case scenario results
3.2.1. Idle state
11
3.2.2. Only smoke detected
12
3.2.4. Both are detected
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