DOI : 10.5281/zenodo.24750285
- Open Access

- Authors : Shrawani Mukkannwar, Ovesh Mujawar, Mukul More, Yash Morde
- Paper ID : IJERTV15IS111746
- Volume & Issue : Volume 15, Issue 11 , November – 2026
- Published (First Online): 02-12-2026
- ISSN (Online) : 2278-0181
- Publisher Name : IJERT
- License:
This work is licensed under a Creative Commons Attribution 4.0 International License
Arduino Based Gas Leakage Detection and Fire Prevention System using MQ-2 and Infrared Flame Sensors
Shrawani Mukkannwar, Ovesh Mujawar, Mukul More, and Yash Morde
Department of Mechanical Engineering Vishwakarma Institute of Technology Pune, Maharashtra, India emails:
Abstract – Gas leakage and fire hazards from Liquefied Petroleum Gas (LPG) poses significant safety threats. It is especially in domestic, commercial and small scale industrial environments. This paper presents an economical, standalone and intelligent Arduino based gas leakage detection and fire prevention system. The system integrates an MQ2 gas sensor and an infrared flame sensor with an Arduino Uno microcontroller. It is provided with a 16×2 liquid crystal display (LCD), alert indicators and relay controlled exhaust and valve systems. A machine learning classification framework is integrated at the edge to mitigate the common limitations of threshold based gas detection. These threshold includes sensor drift and cross sensitivity. The system operates in real time with polling sensors. It is processing temporal characteristics and driving actuators. In the event of a detected leak or flame the system displays alarm messagee and also sounds a buzzer. It activates ventilation fans and automatically isolates the gas source via a servo controlled valve. The prototype was built and validated in a laboratory environment. Its performance results characterized are obtained through sensor response graphs and classifier evaluation. The proposed system demonstrates high sensitivity, low false alarm rates and rapid response times. It is without requiring external internet connectivity. It is presenting a robust local first safety solution.
Index TermsArduino Uno, gas leakage detection, liquefied petroleum gas (LPG), MQ 2 sensor, infrared flame sensor,machine learning.
-
INTRODUCTION
Liquefied Petroleum Gas (LPG) is consisting primarily of propane and butane. It is highly caloric and widely used in households and industries. However the accidental gas leaks are extremely hazardous. It is because they can form explosive mixtures with air. Rapid local detection and immediate mitigation are essential to prevent catastrophic explosions and fire accidents. Consequently the designing automated reliable and low cost embedded systems is essential. This can detect leaks which warn users. It can physically isolate the source which is a key area of safety engineering.
Traditional domestic detectors rely on simple and low cost metal oxide semiconductor gas sensors. It includes MQ2 sensor [1]. These sensors are cost effective but possess notable limitations. It is including non linear responses. This is applicable to long term drift and cross sensitivity to non hazardous substances. These substances includes ethanol and cooking smoke [2], [3]. Standard threshold based detectors activate alarms immediately as soon as the sensor voltage exceeds a static limit. Consequently they frequently trigger
false alarms from cooking vapors. This is to detect slow or low concentration leaks before they reach dangerous thresholds.
Recent advances have incorporated Internet of Things (IoT) platforms to enable remote monitoring and notification capabilities [4][6]. While remote connectivity adds value. It also increases cost, power consumption and vulnerability to network failure. A robust safety system must first and foremost. It operate reliably and locally. Furthermore the integrating Artificial Intelligence (AI) and Machine Learning (ML) techniques can enhance detection accuracy by analyzing the temporal patterns of sensor readings rather than relying on absolute thresholds [7], [8].
In this study, a hybrid, local first safety prototype is proposed that combines threshold based safety overrides with an edge based machine learning classifier. The primary contributions of this paper are:
-
Design and implementation of a standalone, Arduino based gas and fire surveillance prototype with automated ventilation and mechanical gas source isolation.
-
Integration of a lightweight edge machine learning algorithm to analyze temporal features of the MQ-2 sensor. It is significantly reducing false alarm rates. 3) A comprehensive literature comparison spanning recent IoT, ML, and sensor based safety architectures.
4) Empirical evaluation of the system, with results presented through sensor response curves, classifier performance, and response latency graphs.
The rest of the paper is organized as follows: Section II reviews related literature and contrasts existing architectures. Section III describes the hardware and system architecture. Section IV presents the operating principle and rule based logic. Section V details the machine learning classification framework. Section VI discusses experimental results and system latency. It is followed by limitations in Section VII. Section VIII highlights future research, and Section IX concludes the paper.
-
-
RELATED WORK
Research on embedded gas safety and fire prevention systems can be categorized into three main paradigms like local alarm systems, IoT enabled remote monitoring platforms and intelligent machine learning based detectors.
Several classical architectures focus on local detection and basic actuation. Tasnim et al. [1] presented an automated system using MQ 2 and MQ 5 sensors linked to an Arduino Uno for local alarms and exhaust activation. Similarl the Kodali et al.
[9] and Jamadagni et al. [10] explored industrial plant safety using microcontrollers like Arduino and Raspberry Pi. While these prototypes operate locally, their reliance on static thresholds makes them prone to environmental noise and sensor cross-sensitivity.To extend warning ranges th, researchers integrated wireless modules. Gavaskar et al. [11] developed an LPG detector with an automatic exhaust and solenoid valve using PIC microcontrollers and GSM modules. Yahaya et al. [12] and Islam et al. [4] implemented cloud based logging and monitoring using NodeMCU and ESP8266 platforms. Dinesh et al. [13] evaluated universal gas leak detection across multiple hazardous gases in an IoT framework. it is demonstrating cloud telemetry. Naik et al. [5] and Ralevski and Stojkoska [6] explored smart kitchen environments. It is integrating flame and gas sensors with cloud databases. However, these systems remain vulnerable to network latency and outages. It can compromise critical safety actions.
To address the limitations of sensor drift and false alarms the recent studies have incorporated AI and ML. El Barkani et al.
[7] implemented Tiny Machine Learning (TinyML) on an ARM Cortex M4 microcontroller. It is done by using artificial neural networks for high accuracy local gas classification. Salhi et al. [8] applied Support Vector Machines (SVM) and Decision Trees to distinguish between gas leaks and cooking vapors. Rahim et al. [14] enhanced smart home IoT security by deploying logit boosted Convolutional Neural Networks (CNN) for multi sensor anomaly detection. On a larger scale, Zhao et al. [3] reviewed pressure wave analysis in gas pipelines using advanced machine learning, and Yao et al. [15] proposed TSFF Net. It is a lightweight CNN for real time video detection of sulfur hexafluoride (SF6) leaks.TABLE I
Comparison with Representative Gas Safety Prototypes
Ref.
Sensors
Flame
Method
Mitigation / IoT
[7] MQ-2
No
TinyML
Buzzer / No
[1] MQ-2, MQ-5
No
Threshold
Fan, Buzzer / GSM
[11] MQ-6
No
Threshold
Fan, Valve / Blynk
[13] MQ-2, MQ-6
No
Threshold
Buzzer / Cloud
[8] MQ-2, Temp, Hum
Yes
ML (SVM)
Fan, Alarm / Web
[14] Multi-sensor
Yes
CNN
Buzzer, Alarm / Cloud
[15] Optical (SF6)
No
CNN
Valve / Remote
Ours
MQ-2
Yes
Hybrid
Fan, Valve, Buzzer / No
Table I compares various safety systems.
-
SYSTEM ARCHITECTURE AND HARDWARE
X
Sensor
Sensor
The hardware architecture of the proposed system is designed to be economical, modular and robust. It consists of three primary stages which includes input sensing, central processing, and local mitigation or actuation. A block diagram of the system is shown in Fig. 1.
-
MQ2 Gas Sensor
The MQ2 is a metal oxide semiconductor (MOS) gas sensor containing a tin dioxide (SnO2) sensing layer. When exposed to combustible gases such as LPG, propane, butane or smoke, the electrical conductivity of the sensor increases. The sensor is biased with a heater circuit, and its output is read as an analog voltage (Vout) across a load resistor. The Arduinos 10 bit analog to digital converter (ADC) samples Vout to obtain digital values ranging from 0 to 1023. While the MQ2 is highly sensitive. Its response is non linear and cross sensitive to non hazardous gases like ethanol and cooking vapor. It is addressed through machine learning.
-
Infrared Flame Sensor
The infrared (IR) flame sensor is used to detect fire hazards. It operates by sensing infrared radiation in the wavelength range of 760 nm to 1100 nm. It is typical of open flames. The sensor has an onboard comparator that converts the photodiode current into a digital HIGH or LOW output. The digital pin is connected to an external interrupt pin (D2) of the Arduino Uno. It is ensuring that flame detection triggers an immediate system response.
-
Arduino Uno and User Interface
The central processing unit is the Arduino Uno. It is powered by an ATmega328P microcontroller running at 16 MHz with 32 KB of flash memory and 2 KB of SRAM. It handles sensor sampling, feature extraction, edge inference, state control and actuator driving. A 16×2 character LCD with an I2C communication backpack provides real time system status and gas concentration levels to the user.
-
Relay and Actuation
To mitigate hazards automatically, the controller interfaces with two main actuators:
-
Ventilation Fan: A 5V DC fan is controlled via an electromagnetic relay module. When gas levels rises the
fan is activated to dilute and exhaust the accumulated gas.
-
Servo Shutoff Valve: A high torque MG996R servo motor is mechanically coupled to a mock gas supply valve. In an alarmed state the servo rotates to shut off the gas flow. It is isolating the leak source.
-
X
-
The physical electrical connections of the prototype are detailed in the schematic diagram shown in Fig. 2. The analog output of the MQ2 sensor is routed to pin A0.The digital trigger of the flame sensor is linked to the external interrupt pin D2. Output devices like the LCD (via I2C pins), relay driver (pin D3) and servo motor (pin D9) are controlled dynamically based on the state logic.
Fig. 2. Detailed circuit schematic showing the interface and pin wiring.
TABLE II
Hybrid Rule Based and ML Control Logic
|
Input Condition |
State |
Local Response |
|
Gas Vcrit AND Flame = 0 AND ML = 0 |
NORMAL |
LCD: Normal; actuators inactive. |
|
Gas Vcrit AND Flame = 0 AND ML = 1 |
GAS WARN |
LCD: Leak (ML); fan active; valve closed. |
|
Gas > Vcrit |
GAS CRIT |
LCD: CRITICAL!; fan active; valve closed; buzzer. |
|
Flame = 1 |
FIRE ALERT |
LCD: FIRE!; valve closed; continuous buzzer. |
|
Hazard cleared |
RECOVERY |
LCD: Recovering…; fan active; valve open; status check. |
-
MACHINE LEARNING INTEGRATION FOR GAS CLASSIFICATION
To reduce the high false-alarm rate caused by the crosssensitivity of the MQ-2 sensor (e.g., triggering due to ethanol vapor or cooking smoke), we implement a lightweight machine learning classification framework at the edge.
-
Feature Extraction
Instead of relying solely on instantaneous voltage readings, the system captures the temporal dynamics of the MQ2 sensor. Let V (t) represent the sampled voltage at time t. The three features are extracted over a rolling window of size N = 10 seconds:
1) Mean Voltage (mt):
-
OPERATING PRINCIPLE
The system operates on a hybrid control loop that combines safety critical threshold overrides with machine learning verification. The program periodically samples the sensors at a frequency of 1 Hz. Based on the sensor inputs the system transitions between four states:
-
NORMAL: Gas levels are within baseline limits and no flame is detected. All mitigation actuators are inactive.
-
GAS WARNING (ML): Gas levels are elevated and the
-
Temporal Slope (St):
t
-
Variance ( 2):
-
-
Model Selection and Training
(1)
(2)
(3)
edge machine learning model classifies the temporal signature as an active leak. The fan is turned on and the servo valve is shut.
-
GAS CRITICAL: The gas concentration exceeds a critical safety threshold (Vout 2.5V). It is bypassing the ML model to ensure zero latency ventilation and isolation.
-
FIRE ALERT: A flame is detected via the IR sensor. The buzzer sounds a distinct continuous tone. The LCD indicates fire danger and emergency shutoff is initiated.
-
RECOVERY: Following hazard clearance, the system enters a recovery state to allow sensor baseline stabilization before resuming normal monitoring.
Table II outlines the rule based control logic governing state transitions.
A dataset of 1,000 samples was collected under controlled laboratory conditions. It is simulating clean air, LPG leaks, ethanol exposure and cooking smoke. Three classification models are trained offline: Logistic Regression (LR), Support Vector Machines (SVM) and a Random Forest (RF) classifier.
For edge deployment on the 8 bit ATmega328P microcontroller, the Logistic Regression model is selected due to its low memory footprint and simple mathematical formulation. The model evaluates the probability of a gas leak P(leak) using the sigmoid function:
P(leak) = (4)
where the log-odds z is a linear combination of the extracted features:
z = 0 + 1mt + 2St + 3t2 (5)
2
The coefficients = [0,1,2,3] are optimized during offline training using mximum likelihood estimation. The trained coefficients are: 0 = 4.52, 1 = 2.15, 2 = 8.74, and 3 = 1.25. On the Arduino, if P(leak) 0.70, the system flags a leak (ML
= 1). This mathematical computation requires only three multiplications, three additions and one exponential operation. It executes in under 1.2 ms on the Arduino Uno.
-
-
RESULTS AND DISCUSSION
The prototype was evaluated through rigorous laboratory testing. This is to verify both the physical actuation and the intelligence of the detection algorithms.
-
Sensor Response Characterization
gger
4
3
Ethanol Vapor
2
Thresho
1
00
10
20
30
40
50
60
Fig. 3 illustrates the MQ2 voltage response when exposed to different substances. In the clean air baseline the voltage remains stable at approximately 0.5V. When exposed to an LPG leak the sensor output exhibits a sharp with continuous rise. It is exceeding the safety threshold and peaking near 3.5V. In contrast the exposure to ethanol vapor representing household interference causes a temporary voltage rise. It peaks below 2.0V and decays rapidly as the vapor disperses. Under a traditional static threshold system set at 2.0V, both scenarios would trigger an alarm. However this ML classifier analyzes the temporal slope and variance. It also correctly classifying the ethanol exposure as a non leak event while successfully tri gering an alarm for the LPG leak.
Fig. 3. Dynamic voltage response of the MQ-2 sensor to target gas (LPG) vs. common household interference (ethanol vapor) relative to a static threshold.
-
Machine Learning Model Performance
The accuracy, precision and recall of the three candidate classifiers evaluated during offline training are shown in Fig. 4. The Random Forest (RF) classifier achieved the highest accuracy of 98.6% and precision of 98.1%. Support Vector Machines (SVM) performed slightly lower with 96.8% accuracy. The Logistic Regression (LR) classifier achieved a competitive accuracy of 94.2% with precision of 93.5% and recall of 94.8%. Given the restricted SRAM (2 KB) and flash memory of the Arduino Uno, the LR model was selected for edge deployment due to its minimal footprint while still offering robust false alarm rejection.
6
105
100
96. 8
97. 2
98. 98. 199
95. 5
95
94. 93. 94. 8
5
90
85
Fig. 4. Classification performance comparison (Accuracy, Precision, Recall) of candidate machine learning models evaluated for edge deployment.
-
Response Latency Comparison
Fig. 5 shows the response latency of the system. It is the time between gas exposure and fan/valve actuation. It is a function of the gas leak concentration. Because the ML classifier evaluates the temporal slope ( ), it detects a gas leak significantly faster at lower concentrations (e.g., 4.2 s at 100 PPM) compared to the traditional static threshold system. It must wait for the absolute concentration to build up to cross the threshold of 10.5 s at 100 PPM. At high concentrations of about
ppro
e ri
12
10
8
6
4
2
0
100
300
500
700
900 1,000
> 800 PPM, both systems respond rapidly. The ML enhanced a pr ach consistently reduces mitigation latency. It minimizing th risk of hazardous accumulation.
Fig. 5. Mitigation latency comparison between traditional static threshold and ML enhanced methods across various gas concentrations.
-
Qualitative Functional Validation
Table III details the qualitative responses observed during testing. The physical and algorithm logic operated correctly across all ambient and hazard conditions, verifying the local mitigation loop.
-
-
LIMITATIONS AND SAFETY CONSIDERATIONS
While the integration of machine learning and local physical mitigation improves performance the several engineering limitations must be recognized: The sensor MQ2 sensor cannot distinguish between specific hydrocarbon components without intensive multi point calibration. Environmental parameters
TABLE III Qualitative Functional Test Results
Test
Sensor Response
System Response
Evidence
Ambient
Stable baseline.
Normal LCD status.
Observation
LPG Leak
MQ-2 voltage rises rapidly.
Fan active; valve closed; LCD alarm.
Test report
Flame
IR sensor triggers.
Buzzer active; valve closed; LCD fire.
Test report
Recovery
Voltage returns to baseline.
Fan active; system resets.
Observation
like temperature and relative humidity. It also influence sensor resistance and should be monitored to implement software compensation. The ATmega328P has severe memory limitations. It is restricting the complexity of edge machine learning models. High dimensional networks cannot be executed directly on the board without external coprocessors. The prototype was evaluated on a breadboard. In explosive gas environments. The electrical contacts can generate ignition arcs. Practical deployment requires adherence to explosive atmosphere safety guidelines such as IEC 60079 14:2024 [2]
and IS/IEC 60079 29 1:2016 [3]. General purpose DC fans are unsafe for flammable atmospheres and must be replaced with explosion proof brushless motors.
-
CONCLUSION
This paper presented an intelligent, economical Arduino based gas leakage detection and fire prevention system. The system integrates MQ2 gas and IR flame sensors with automatic mitigation actuators. It is including an exhaust fan and a mechanical gas isolation servo. To overcome the high false alarm rates typical of metal oxide gas sensors, a lightweight Logistic Regression model was deployed at the edge. The system demonstrated rapid response times. It is robust false alarm rejection under common household interference such as ethanol vapor. It also considers an immediate safety overrides under critical concentrations. While the prototype operates effectively in laboratory conditions, future efforts will transition the design into an industrially certified. It is intrinsically safe system suitable for field deployment.
-
FUTURE WORK
Future development will focus on transitioning the prototype to an industrial grade system. Upgrading the platforms such as the ESP32 or Arduino Nano 33 BLE Sense will allow the deployment of more robust classifiers [7]. Redesigning the system on a multi layer printed circuit board (PCB) enclosed in an intrinsically safe, flameproof casing. Integrating humidity and temperature sensors to dynamically adjust the MQ2 calibration curve can reduce false alarms under fluctuating environmental conditions.
ACKNOWLEDGMENT
The authors express their gratitude to the Department of Mechanical Engineering, Vishwakarma Institute of Technology, Pune for providing laboratory facilities, technical guidance, and support throughout the design and testing of the prototype.
REFERENCES
-
Z. Tanim, S. Das, R. Islam, J. Biswas, F. J. M. Shamrat, and A. Khater, Sensor based smart automated gas leakage detection and prevention system, in 2022 6th International Conference on Trends in Electronics and Informatics (ICOEI). IEEE, 2022, pp. 460466.
-
Z. Wang, C. Hu, D. Zheng, and X. Chen, Ultralow-power sensing framework for internet of things: A smart gas meter as a case, IEEE Internet of Things Journal, vol. 9, no. 10, pp. 75337544, 2021.
-
L. Zhao, Z. Cao, and J. Deng, A review of leak detection methods based on pressure waves in gas pipelines, Measurement, vol. 236, p. 115062, 2024.
-
G. Z. Islam, M. M. Hossain, M. Faruk, F. N. Nur, N. Hasan, M. K. M. Khan, and Z. N. Tumpa, Iot-based intelligent gas leakage detection and fire protection system. Int. J. Interact. Mob. Technol., vol. 16, no. 21,
pp. 4970, 2022.
-
G. M. Naik, C. Singh, E. Thejaswini, R. Kumari, and Anulokesh, Iotbased gas leak and fire detection system, in Data Science and Applications (ICDSA 2024), ser. Lecture Notes in Networks and Systems. Singapore: Springer, 2025, vol. 1263.
-
M. Ralevski and B. R. Stojkoska, Iot based system for detection of gas leakage and house fire in smart kitchen environments, in 2019 27th Telecommunications Forum (TELFOR). IEEE, 2019, pp. 14.
-
M. El Barkani, N. Benamar, H. Talei, and M. Bagaa, Gas leakage detection using tiny machine learning, Electronics, vol. 13, no. 23, p. 4768, 2024.
-
L. Salhi, T. Silverston, T. Yamazaki, and T. Miyoshi, Early detection system for gas leakage and fire in smart home using machine learning, in 2019 IEEE International Conference on Consumer Electronics (ICCE). IEEE, 2019, pp. 16.
-
R. K. Kodali, R. Greeshma, K. P. Nimmanapalli, and Y. K. Y. Borra, Iot based industrial plant safety gas leakage detection system, in 2018 4th international conference on computing communication and automation (ICCCA). IEEE, 2018, pp. 15.
-
S. Jamadagni, P. Sankpal, S. Patil, N. Chougule, and S. Gurav, Gas leakage and fire detection using raspberry pi, in 2019 3rd International conference on computing methodologies and communication (ICCMC). IEEE, 2019, pp. 495497.
-
K. Gavaskar, D. Malathi, G. Ravivarma, and A. Arulmurugan, Development of lpg leakage detection alert and auto exhaust system using iot, in 2021 7th International Conference on Electrical Energy Systems (ICEES). IEEE, 2021, pp. 558563.
-
S. Yahaya, M. M. Zailani, Z. C. Soh, and K. Ahmad, Iot based system for monitoring and control of gas leaking, in 2020 1st International Conference on Information Technology, Advanced Mechanical and Electrical Engineering (ICITAMEE). IEEE, 2020, pp. 122127.
-
D. Dinesh, A. N. Mowshik, M. Meyyappan, and M. Kowtham, Analysis of universal gas leak detector of hazardous gases using iot, Materials Today: Proceedings, vol. 66, pp. 10441050, 2022.
-
A. Rahim, Y. Zhong, T. Ahmad, S. Ahmad, P. Pawiak, and M. Hammad, Enhancing smart home security: anomaly detection and face recognition in smart home iot devices using logit-boosted cnn models, Sensors, vol. 23, no. 15, p. 6979, 2023.
-
J. Yao, Z. Xiong, S. Li, Z. Yu, and Y. Liu, Tsff-net: A novel lightweight network for video real-time detection of sf6 gas leaks, Expert Systems with Applications, vol. 247, p. 123219, 2024.
