Lights an LED and sounds a buzzer on flames or a gas leak.
Built and tested by Shahan Fathima K · Industrial Robotics Institute

A safety alarm for kitchens, homes and workshops. A flame sensor watches for fire and an MQ-2/MQ-135 gas sensor checks for harmful gas. The ESP8266 reads both several times a second and turns on a warning LED and buzzer the moment either one detects danger.
| Component | Qty |
|---|---|
| ESP8266 NodeMCU | 1 |
| Flame Sensor Module | 1 |
| Gas Sensor (MQ-2 / MQ-135) | 1 |
| Buzzer | 1 |
| LED | 1 |
| Resistor 220Ω (for LED) | 1 |
| Jumper Wires | As needed |
| Power Supply | 1 |
| From | Connect to |
|---|---|
| Flame sensor VCC | 3.3V |
| Flame sensor GND | GND |
| Flame sensor OUT | D1 |
| Gas sensor VCC | 5V (VIN) |
| Gas sensor GND | GND |
| Gas sensor AOUT | A0 |
| LED + (via resistor) | D2 |
| Buzzer + | D3 |
| LED − / Buzzer − | GND |
Complete, tested Arduino C++ code for this project. Copy it into Arduino IDE and upload it to the ESP8266 NodeMCU.
#define flamePin D1
#define gasPin A0
#define ledPin D2
#define buzzer D3
int gasValue = 0;
void setup()
{
pinMode(flamePin, INPUT);
pinMode(ledPin, OUTPUT);
pinMode(buzzer, OUTPUT);
}
void loop()
{
int flame = digitalRead(flamePin); // LOW = flame detected
gasValue = analogRead(gasPin);
if (flame == LOW || gasValue > 400)
{
digitalWrite(ledPin, HIGH);
digitalWrite(buzzer, HIGH);
}
else
{
digitalWrite(ledPin, LOW);
digitalWrite(buzzer, LOW);
}
delay(200);
}A safety alarm for kitchens, homes and workshops. A flame sensor watches for fire and an MQ-2/MQ-135 gas sensor checks for harmful gas.
You need: ESP8266 NodeMCU (1), Flame Sensor Module (1), Gas Sensor (MQ-2 / MQ-135) (1), Buzzer (1), LED (1), Resistor 220Ω (for LED) (1), Jumper Wires, Power Supply (1). Software: Arduino IDE.
Yes. It is rated beginner and takes about 1–2 hours to build, using the ESP8266 NodeMCU. 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-067). Message IRI on WhatsApp at +91 86060 82634 for the kit price and delivery details.