Embedded SystemsBeginnerPRJ-012

Gas Leakage and Flame Detection System Using Arduino

Sounds an alarm and turns the light red the moment gas or fire is detected.

Built and tested by Radul Krishna P · Industrial Robotics Institute

Circuit diagram of the Gas Leakage and Flame Detection System using Arduino Uno
Circuit diagram · Arduino Uno
LevelBeginner
Build time1–2 hours
BoardArduino Uno
Parts9 components

What is the Gas Leakage and Flame Detection System?

Gas leaks and fires are serious hazards in homes, labs and industries. This Arduino system watches for both: an MQ-2 sensor detects LPG, methane, propane and smoke, and a flame sensor detects the infrared light from fire. A green LED shows that everything is safe; on danger, the red LED lights and the buzzer sounds.

How it works

  1. The MQ-2 gas sensor signals the Arduino when gas or smoke goes above a safe level.
  2. The flame sensor signals the Arduino when it sees the infrared light from a flame.
  3. Under normal conditions the green LED stays on.
  4. If either sensor detects danger, the red LED turns on, the green LED turns off and the buzzer sounds.
  5. The Arduino checks both sensors continuously.

Parts list

ComponentQty
Arduino Uno1
MQ-2 Gas Sensor Module1
Flame Sensor Module1
Buzzer1
Green LED1
Red LED1
Breadboard1
Jumper WiresAs needed
Power Supply (USB or 9V battery)1

Software

  • Arduino IDE

Wiring and connections

FromConnect to
MQ-2 VCC / GND5V / GND
MQ-2 OUTPin 2
Flame sensor VCC / GND5V / GND
Flame sensor OUTPin 3
Buzzer +Pin 8
Buzzer −GND
Green LED anodePin 9
Red LED anodePin 10
LED cathodesGND

How to build the Gas Leakage and Flame Detection System

  1. Place the Arduino and breadboard, and run 5V and GND to the breadboard rails.
  2. Connect the MQ-2 gas sensor output to pin 2 and the flame sensor output to pin 3.
  3. Connect the buzzer to pin 8, the green LED to pin 9 and the red LED to pin 10.
  4. Upload the code from the Arduino IDE.
  5. Let the MQ-2 sensor warm up for a few minutes.
  6. Adjust the sensitivity screws on the sensor modules if they trigger too easily.
  7. Test safely: bring a lighter flame near the flame sensor (do not leave it unattended).

Gas Leakage and Flame Detection System code

Complete, tested Arduino C++ code for this project. Copy it into Arduino IDE and upload it to the Arduino Uno.

int gasSensor = 2;
int flameSensor = 3;

int buzzer = 8;
int greenLED = 9;
int redLED = 10;

void setup()
{
  pinMode(gasSensor, INPUT);
  pinMode(flameSensor, INPUT);
  pinMode(buzzer, OUTPUT);
  pinMode(greenLED, OUTPUT);
  pinMode(redLED, OUTPUT);

  digitalWrite(greenLED, HIGH);
  digitalWrite(redLED, LOW);

  Serial.begin(9600);
}

void loop()
{
  int gasValue = digitalRead(gasSensor);
  int flameValue = digitalRead(flameSensor);

  if (gasValue == LOW || flameValue == LOW)
  {
    digitalWrite(buzzer, HIGH);
    digitalWrite(redLED, HIGH);
    digitalWrite(greenLED, LOW);
  }
  else
  {
    digitalWrite(buzzer, LOW);
    digitalWrite(redLED, LOW);
    digitalWrite(greenLED, HIGH);
  }
}

Real-world uses

  • Home kitchens
  • Laboratories
  • Industries and warehouses
  • Restaurants

Frequently asked questions

What is a Gas Leakage and Flame Detection System?

Gas leaks and fires are serious hazards in homes, labs and industries. This Arduino system watches for both: an MQ-2 sensor detects LPG, methane, propane and smoke, and a flame sensor detects the infrared light from fire.

What components are needed for the Gas Leakage and Flame Detection System?

You need: Arduino Uno (1), MQ-2 Gas Sensor Module (1), Flame Sensor Module (1), Buzzer (1), Green LED (1), Red LED (1), Breadboard (1), Jumper Wires, Power Supply (USB or 9V battery) (1). Software: Arduino IDE.

Is the Gas Leakage and Flame Detection System project good for beginners?

Yes. It is rated beginner and takes about 1–2 hours to build, using the Arduino Uno. The guide on this page explains every connection and step.

Where can I get the code for the Gas Leakage and Flame Detection System?

The complete, tested Arduino C++ code is free on this page. Copy it into Arduino IDE and upload it to the board.

Can I buy a kit for the Gas Leakage and Flame Detection System?

Yes. IRI sells a kit with the parts for this project (PRJ-012). Message IRI on WhatsApp at +91 86060 82634 for the kit price and delivery details.

Industrial Robotics Institute
Logo