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

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.
| Component | Qty |
|---|---|
| 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 | As needed |
| Power Supply (USB or 9V battery) | 1 |
| From | Connect to |
|---|---|
| MQ-2 VCC / GND | 5V / GND |
| MQ-2 OUT | Pin 2 |
| Flame sensor VCC / GND | 5V / GND |
| Flame sensor OUT | Pin 3 |
| Buzzer + | Pin 8 |
| Buzzer − | GND |
| Green LED anode | Pin 9 |
| Red LED anode | Pin 10 |
| LED cathodes | GND |
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);
}
}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.
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.
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.
The complete, tested Arduino C++ code is free on this page. Copy it into Arduino IDE and upload it to the board.
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.