Arduino Fire Alarm System Using Flame Sensor and MQ-2 Gas Sensor

Arduino Fire Alarm System Using Flame Sensor and MQ-2 Gas Sensor

In commercial buildings and industries, fire alarm systems are quite popular, they usually include a cluster of sensors that continually monitor any building flame, gas, smoke, or fire and cause an alarm if they detect them. One of the easiest ways to detect fire, gas, and smoke is by utilizing a Flame sensor and MQ 2 Gas Sensor.

This article interfaces Flame Sensor and MQ 2 Gas Sensor with Arduino and learns about all the procedures needed to develop Arduino Fire Alarm System. The flame sensor module has a photodiode for light detection and an op-amp for sensitivity monitoring. It is used for fire detection and makes a HIGH signal. Arduino detects the signal and alerts the buzzer and LED by turning it on. The flame sensor utilized is a flame sensor based on IR.

The MQ 2 sensor has an electrochemical sensor that varies its resistance to different flammable gas concentrations. The sensor is connected to a voltage divider circuit in series with a variable resistor, and the variable resistor is used to change sensitivity. When flammable gaseous elements come into contact with the sensor, it is heated. As a result, the sensor’s resistance changes. The voltage across the sensor changes as the resistance changes and this value can be read by a microcontroller. Here Arduino read the value and turning on the buzzer and LED.

Components required the Arduino Fire Alarm

Arduino Uno× 1Amazon
Flame Sensor× 1Amazon
MQ-2 Gas & Smoke Sensor× 1Amazon
Breadboard× 1Amazon
Jumper wires kit× 1Amazon
LED and Resistor Kit× 1Amazon
Buzzer×2Amazon
USB cable type A/B× 1Amazon

Software

Arduino IDE

Flame Sensor

The flame sensor module is a small electronic module capable of detecting a fire source or other light sources. This sensor basically detects light wave IR (Infrared) from a light source or from a fire flame between 760 nm – 1100 nm. The flame sensor has a high-speed and sensitive YG1006 photo-transistor sensor. The detecting range is 100 cm. The Flame sensor can output either a digital or analog signal. There are two types of IR Infrared Flame Sensor Modules on the market: one with three pins (D0, Gnd, Vcc) and one with four pins (A0, D0, Gnd, Vcc), both of them can be used with Arduino and other microcontroller boards.

This sensor has a potentiometer, a 10k preset. Adjust the sensitivity of the flame sensor by rotating the preset knob. The Flame Sensor sensitivity will increase if the preset knob rotates clockwise. The sensitivity of the Flame sensor will decrease if it rotates counter-clockwise.

Application

  • Fire detection
  • Use in Fire fighting robot
  • Fire alarm

Flame Sensor Specifications

Operating  voltage3.3V – 5V
Operating current consumption15mA
Spectrum range760nm ~ 1100nm
Detecting range100 cm
Sensor typeYG1006 Photo Transistor
SensitivityAdjustable via potentiometer
Detection angle0 – 60 degree
Operating temperature-25℃ ~ 85℃
PCB Size3cm X 1.6cm
CostCheck price

For more information, you can check out the flame sensor datasheet below:

MQ 2 Gas Sensor

MQ-2 sensitive gas sensor material is SnO2, which has a lower clean air conductivity.   The conductivity of the sensor increases with the increase of the gas concentration when the target inflammable gas is present. Users can convert the change of conductivity by a single circuit to the corresponding gas concentration output signal.
The MQ-2 gas sensor is highly propane-smoke-sensitive and can well detect gas and other flammable steam. It’s cheap and suitable for various The MQ-2 gas sensor is highly propane-smoke-sensitive and can well detect gas and other flammable steam. It’s cheap and suitable for various applications of flammable gas detection.

  • Wide range good sensitivity to Combustible gases
  • High sensitivity to LPG, Propane and Hydrogen
  • Long life and low cost
  • Simple drive circuit

Application

  • Domestic gas leakage detector
  • Industrial Combustible gas detector
  • Portable gas detector
  • Safety of home
  • Control of air quality
  • Measurement of gas level

MQ 2 Gas Sensor Specifications

Operating  voltage4.5V – 5.V
Sensor TypeSemiconductor
SensitivityAdjustable via potentiometer
Gas to measureLPG, i-butane, propane, methane, alcohol, Hydrogen, smoke
Detection range300~10000ppm (flammable gas)
CostCheck price

For more information, you can check out the MQ 2 Gas Sensor datasheet below:

Arduino Fire Alarm Schematics

Arduino Fire Alarm Schematics

Flame Sensor Connections

Flame SensorArduino
VCC5 V
GNDGND
D0Digital pin 2

MQ 2 Gas Sensor Connections

MQ 2 Gas SensorArduino
VCC5 V
GNDGND
A0A0

LED and Buzzer Connections

LED and BuzzerArduino
Green LEDDigital Pin 8
MQ 2 Gas Sensor Red LEDDigital Pin 3
Flame Sensor Red LEDDigital Pin 4
MQ 2 Gas Sensor BuzzerDigital Pin 5
Flame Sensor BuzzerDigital Pin 6

Arduino Fire Alarm Code

By clicking the button in the top right corner of the code field, you can copy the code. Copy and paste it into Arduino IDE. 

/*
www.arduinopoint.com 
Fire Alarm System 
*/

int redLed1 = 3;
int redLed2 = 4;
int greenLed = 8;
int buzzer1 = 5; //PWM (~) pin
int buzzer2 = 6; //PWM (~) pin
int gasPin = A0;
int flamePin = 2;
// Your threshold value
int gasSensorThres = 400;

void setup() {
  pinMode(redLed1, OUTPUT);  
  pinMode(redLed2, OUTPUT);
  pinMode(greenLed, OUTPUT);
  pinMode(buzzer1, OUTPUT);
  pinMode(buzzer2, OUTPUT);
  pinMode(gasPin, INPUT);
  pinMode(flamePin, INPUT);
  Serial.begin(9600);
}

void loop() {
  int gasSensor = analogRead(gasPin);
  int flameSensor = digitalRead(flamePin);
  
  Serial.print("gasPin Value: ");
  Serial.println(gasSensor);
  Serial.print("flamePin Value: ");
  Serial.println(flameSensor);
  delay(1000);
  
  if (gasSensor > gasSensorThres  && flameSensor==LOW){
   digitalWrite(redLed1, HIGH);
    tone(buzzer1, 5000); //the buzzer sound frequency at 5000 Hz
    digitalWrite(redLed2, HIGH);
    tone(buzzer2, 5000); //the buzzer sound frequency at 5000 Hz
    digitalWrite(greenLed, LOW);
  }
   else if (gasSensor > gasSensorThres)
  {
    digitalWrite(redLed1, HIGH);
    tone(buzzer1, 5000); //the buzzer sound frequency at 5000 Hz
    digitalWrite(redLed2, LOW);
    noTone(buzzer2);
    digitalWrite(greenLed, LOW);
  }
  else if (flameSensor==LOW){ // HIGH MEANS NO FLAME
    digitalWrite(redLed1, LOW);
    noTone(buzzer1);
    digitalWrite(redLed2, HIGH);
    tone(buzzer2, 5000); //the buzzer sound frequency at 5000 Hz
    digitalWrite(greenLed, LOW);
    }
  
  else
  {
    digitalWrite(redLed1, LOW);
    digitalWrite(redLed2, LOW);
    noTone(buzzer1);
    noTone(buzzer2);
    digitalWrite(greenLed, HIGH);    
  }
}

Result

You should see your LED and Buzzer turn on when the sensor detects a fire, flammable gas, or smoke. If you cannot see the desired output, ensure the circuit has been properly assembled, and verified, and uploaded the code to your board.

Leave a Reply