Arduino Fire Alarm

In this tutorial, we are going to learn how to make a fire alarm system that detects the fire and make alarm via siren and light.

Hardware Required

1×Arduino UNO or Genuino UNO
1×USB 2.0 cable type A/B (for USB-A PC)
1×USB 2.0 cable type C/B (for USB-C PC)
1×Smoke Sensor (MQ2 Gas Sensor)
1×Flame Sensor
1×5-in-1 5-way Flame Sensor
1×Relay
1×12V Fire Alarm Siren Horn
1×(Alternative) 12V Active Buzzer
1×12V Power Adapter
1×DC Power Jack
1×Jumper Wires
1×(Recommended) Screw Terminal Block Shield for Arduino Uno
1×(Recommended) Breadboard Shield For Arduino Uno
1×(Recommended) Enclosure For Arduino Uno

Or you can buy the following sensor kits:

1×DIYables Sensor Kit (30 sensors/displays)
1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some links in this section are Amazon affiliate links. If you make a purchase through these links, we may earn a commission at no extra cost to you.
Additionally, some links direct to products from our own brand, DIYables.

About Fire Alarm System

The fire alarm system includes two parts:

  • The fire detection: can use the smoke sensor (MQ2 gas sensor) and/or flame sensor
  • The alarm: can be a siren (including light and sound), or buzzer (sound only)

In the fire detection, you can use one of two sensors. However, to increase the reliability, we recommend to use both the smoke sensor and flame sensor. If you use one sensor, the system may not detect the fire in some location in your momitoring area.

If you do not know about mq2 gas sensor and flame sensor (pinout, how it works, how to program ...), learn about them in the following tutorials:

How Fire Alarm System Works

Arduino reads the states from the smoke sensor and flame sensor, if either smoke or flame is detected, Arduino activate the relay to trigger an alarm.

Wiring Diagram

  • Wiring diagram with a siren
Arduino fire alarm siren system Wiring Diagram

This image is created using Fritzing. Click to enlarge image

  • Wiring diagram with a 12V buzzer
Arduino fire alarm siren system Wiring Diagram

This image is created using Fritzing. Click to enlarge image

Arduino Code

/* * Created by ArduinoGetStarted.com * * This example code is in the public domain * * Tutorial page: https://arduinogetstarted.com/tutorials/arduino-fire-alarm */ #define FLAME_PIN 7 // Arduino's pin connected to DO pin of the flame sensor #define SMOKE_PIN 13 // Arduino's pin connected to DO pin of the smoke MQ2 sensor #define RELAY_PIN 2 // Arduino's pin connected to relay void setup() { // initialize serial communication Serial.begin(9600); // initialize the Arduino's pin pinMode(FLAME_PIN, INPUT); pinMode(SMOKE_PIN, INPUT); pinMode(RELAY_PIN, OUTPUT); } void loop() { int flame_state = digitalRead(FLAME_PIN); int smoke_state = digitalRead(SMOKE_PIN); if (flame_state == LOW) { Serial.println("Fire is detected based on the flame sensor => alarming"); digitalWrite(RELAY_PIN, HIGH); } else if (smoke_state == LOW) { Serial.println("Fire is detected based on the smoke sensor => alarming"); digitalWrite(RELAY_PIN, HIGH); } else { Serial.println("No fire detected => great!"); digitalWrite(RELAY_PIN, LOW); } }

Quick Steps

  • Copy the above code and open with Arduino IDE
  • Click Upload button on Arduino IDE to upload code to Arduino
  • Open Serial Monitor on Arduino IDE
  • Upload the code to Arduino
  • Create some smoke around the smoke sensor
  • Create a flame in front of the flame sensor
  • Listen to sound alarm from the sire or buzzer
  • See the result on Serial Monitor.
COM6
Send
No fire detected => great! No fire detected => great! No fire detected => great! Fire is detected based on the smoke sensor => alarming Fire is detected based on the smoke sensor => alarming Fire is detected based on the smoke sensor => alarming Fire is detected based on the smoke sensor => alarming No fire detected => great! No fire detected => great! No fire detected => great! Fire is detected based on the flame sensor => alarming Fire is detected based on the flame sensor => alarming Fire is detected based on the flame sensor => alarming
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

Code Explanation

Read the line-by-line explanation in the comment lines of the source code!

Video Tutorial

We are considering to make the video tutorials. If you think the video tutorials are essential, please subscribe to our YouTube channel to give us motivation for making the videos.

The Best Arduino Starter Kit

※ OUR MESSAGES