Both businesses and homes can lose many important things in fires. The Internet of Things is one of today's growing technologies, and in this scenario I am attempting to solve this problem using IoT technology.
Flame sensors are used to detect a fire by using infrared technology. Infrared bulbs are placed at the front of a flame sensor. This sensor comes in three types:
-
Analog Out pin [AO]
-
Digital Out pin [D0]
-
Both Analog [AO] & Digital out pins [DO]
By reading this article, you will learn how to create a fire alarm system using Arduino UNO R3
Prerequisites for creating this system
Hardware Requirement
Hardware
|
Qty |
Arduino UNO R3 |
1 |
Flame Sensor |
1 |
Piezo buzzer |
1 |
LED Bulb |
1 |
220-ohm Resistor |
1 |
Jumper Wires |
- |
Software Requirement
Arduino IDE (Integrated Development Environment)
It has three stages for developing this fire detection alarm system.
-
Connect hardware
-
Write & upload code to Arduino UNO
-
Test our developed system
Stage 1 [Connect Hardware]
First, we are connecting a flame sensor, Piezo buzzer and Led bulb to Arduino. Refer to the below diagram for making this connection.
Pin Configuration
Step 1
Connect a flame sensor to Arduino with a Digital Pin by the below pin configuration:
Pin configuration
Flame Sensor Arduino
VCC------------------------------------> +5V
GND------------------------------------> GND
DO --------------------------------------> Digital pin8
Step 2
Next, connect a Piezo Buzzer to Arduino to make an alarm sound. There is no need to use a resistor for the Buzzer connection.
Pin configuration
Piezo Buzzer Arduino
(+) ---------------------------------------------> Digital pin9
(-) ---------------------------------------------> Digital pin GND
Step 3
Connect Led bulb to Arduino for a flashing light for the fire alert warning.
Pin configuration
Led bulb Arduino
(+) --------------------------------------------> Digital pin10
(-) --------------------------------------------> Digital pin GND
We successfully made the hardware connection :).
Stage 2 [Write and upload code to Arduino]
In this step, write code for Arduino using the Arduino IDE.
- Download Arduino software using this link here.
- Install and open an Arduino IDE in your PC/Laptop.
- Connect your Arduino board to your computer using a USB data cable.
- Copy and paste below the code into the Arduino IDE.
- #define Fire_sensor 8
- #define Buzzer 9
- #define Light 10
- #define ldelay 500
- #define bdelay 500
- void setup() {
- Serial.begin(9600);
- pinMode(Fire_sensor, INPUT);
- pinMode(Buzzer, OUTPUT);
- pinMode(Light, OUTPUT);
- }
- void loop() {
- if (int a = digitalRead(Fire_sensor) == LOW) {
- alert();
- } else {
- digitalWrite(Buzzer, LOW);
- digitalWrite(Light, LOW);
- }
- }
- void alert() {
- digitalWrite(Light, HIGH);
- digitalWrite(Buzzer, HIGH);
- delay(ldelay);
- digitalWrite(Light, LOW);
- digitalWrite(Buzzer, LOW);
- delay(ldelay);
- digitalWrite(Light, HIGH);
- digitalWrite(Buzzer, HIGH);
- delay(ldelay);
- digitalWrite(Light, LOW);
- digitalWrite(Buzzer, LOW);
- delay(ldelay);
- digitalWrite(Light, HIGH);
- digitalWrite(Buzzer, HIGH);
- delay(ldelay);
- digitalWrite(Light, LOW);
- digitalWrite(Buzzer, LOW);
- delay(ldelay);
- }
Save and upload this code to the Arduino UNO board. After the code upload is completed, the device can start to detect any fire in a fixed area.
Stage 3 [Test our developed system]
Our developed system can now get ready to detect fire. I am using a match box for making fire to test our fire detection alarm system.
Finally, the fire detection system gets alarmed and a red light indicates when fire can be detected by a sensor. This system successfully works.