International Journal of Research and Innovation in Social Science

Submission Deadline- 28th August 2025
August Issue of 2025 : Publication Fee: 30$ USD Submit Now
Submission Deadline-04th September 2025
Special Issue on Economics, Management, Sociology, Communication, Psychology: Publication Fee: 30$ USD Submit Now
Submission Deadline-19th September 2025
Special Issue on Education, Public Health: Publication Fee: 30$ USD Submit Now

IoT-Based Real-Time Smoke and Gas Leak Detection System Using ESP8266 And MQ2 Sensor

  • Jeffrey M. Lopez
  • Nikko D. Paña
  • Joseph L. Lunod
  • Jan Smith D. Hermitaño
  • Philip B. Despares
  • 3633-3638
  • Jul 10, 2025
  • Engineering

IoT-Based Real-Time Smoke and Gas Leak Detection System Using ESP8266 And MQ2 Sensor

1Jeffrey M. Lopez, 2Nikko D. Paña, 3Joseph L. Lunod, 4Jan Smith D. Hermitaño, 5Philip B. Despares

College of Technology, Davao City Philippines, University of Southeastern Philippines

DOI: https://dx.doi.org/10.47772/IJRISS.2025.906000273

Received: 20 May 2025; Accepted: 04 June 2025; Published: 10 July 2025

ABSTRACT

These days, it is crucial to protect yourself against indoor hazards like smoke and dangerous gasses, particularly in small, enclosed spaces like homes or even workplaces. This study demonstrates how a basic system was developed to monitor for gas and smoke in real time. Most people don’t consider it, but one malfunctioning appliance or undetected leak can already put everyone at risk. Thus, it monitors the air quality using an ESP8266 NodeMCU and a MQ2 sensor. In order to identify any hazard, the system compares the analog values sent by the sensor to predetermined limits, which are 450 for smoke and 300 for gas. When gas or smoke levels exceed the defined thresholds, the system triggers a buzzer for local alerts and simultaneously sends notifications to a mobile device through the Blynk mobile application. Real-time sensor data and system status are displayed in the Blynk mobile app, and a virtual reset button is included to allow users to clear alerts and deactivate the buzzer remotely. The firmware uses conditional flags to prevent repeated alerts for the same hazard event, ensuring efficient performance and avoiding notification spamming. This implementation demonstrates the integration of low-cost, off-the-shelf components with cloud-based mobile platforms to provide a reliable and responsive safety system. System testing shows that the device can effectively detect changes in gas and smoke concentration, respond within one second, and update the user interface accordingly. In conclusion, the proposed system meets its objectives by delivering a functional, cost-effective, and user-friendly air monitoring device that enhances safety through early warning alerts and real-time control, making it suitable for residential and small-scale applications.

Index Terms: IoT, Smoke and Gas Detection, ESP8266, MQ2 Sensor, Blynk.

INTRODUCTION

The accelerated progress of embedded systems and wireless communication technologies has opened new possibilities for enhancing public safety through the Internet of Things (IoT). These days, one big worry at home, in offices, and even in factories is the risk of gas leaks or smoke from fires. It’s not just about damage to property—these things can actually hurt people or even cost lives. The usual smoke and gas detectors work okay, but they mostly just sound an alarm on-site. That’s not much help if no one’s around to hear it or act fast.

This project focuses on building a real-time smoke and gas detection system using the ESP8266 NodeMCU and an MQ2 sensor. The sensor can pick up smoke, LPG, methane, and even carbon monoxide. With Wi-Fi connection, the system uses the Blynk app to show live data from the sensor. The mobile app makes it easier to monitor what’s happening, anytime. Once the readings go beyond the safe level, the system turns on a buzzer nearby and also sends an alert straight to the user’s phone.

To avoid repetitive alerts and reduce false alarms, the system uses flags (smokeNotified and gasNotified) in the program logic to ensure that notifications are only sent once per event until manually reset by the user through a virtual button in the app. This feature offers a more controlled and user-responsive experience. The integration of a local alarm and mobile alert system ensures that even if no one is physically present near the device, the user is still informed of the danger.

Furthermore, the system is designed to be financially feasible, portable, and easy to set up, making it highly suitable for household safety, small offices, school laboratories, and rental properties. The code is structured to be flexible, allowing customization of threshold values for different environments or levels of sensitivity. This paper highlights not only the technical implementation but also the potential social impact of a simple, cost-efficient, and scalable IoT safety solution that empowers individuals to act quickly in response to environmental threats.

Related Work

Various projects have utilized the MQ2 gas sensor in Arduino-based systems for detecting smoke, methane, LPG, and other combustible gases [1], [3]. These sensors work well for safety purposes, but most just rely on basic alarms like buzzers or lights. They don’t really offer remote monitoring or any smart features. But now that wireless tech has improved, we can use Wi-Fi modules like the ESP8266 NodeMCU with apps like Blynk. This lets the system send real-time data to a phone, log info online, and send alerts right away—making the whole setup more useful and accessible [2,] [4], [6]. However, many of these existing systems still face limitations, such as lack of intelligent event management, manual reset functions, and the potential for repeated alarms due to fluctuating gas levels. This project builds on those foundations by integrating conditional logic to prevent redundant alarms, adding real-time push notifications, and offering a reset feature via the Blynk app. This approach provides a more user-friendly, responsive, and reliable solution for smoke and gas detection, making it an affordable option for homes and small businesses that prioritize safety.

System Overview

Block Diagram of the System

Fig. 1 shows the block diagram of the developed smoke and gas detection system, in which an MQ2 gas sensor continuously measures ambient smoke and flammable gas concentrations and sends an analog signal to an ESP8266 NodeMCU microcontroller. The microcontroller reads this value on A0, compares it against predefined smoke (450) and gas (300) thresholds, and, if exceeded, activates a buzzer on D5 for a local audible alert. Simultaneously, the ESP8266 transmits the real‑time sensor reading to the Blynk Cloud—where the Blynk app displays live values on virtual pin V1, shows status updates such as “DANGER – SMOKE!” or “DANGER – GAS!” on V0, and logs events—and also provides a virtual reset button on V2 that the user can press to clear alerts and silence the buzzer.

Overview of the Proposed Smoke and Gas Detection system

Fig. 1. Overview of the Proposed Smoke and Gas Detection system.

Flow Control

Fig. 2 illustrates the system’s decision‑making process in a single loop: the MQ2 sensor measures ambient gas levels and sends the analog value to the ESP8266, which compares it against the smoke (450) and gas (300) thresholds; if the smoke threshold is exceeded, the buzzer sounds and a “DANGER – SMOKE!” alert is sent once to the Blynk app; if instead the gas threshold is exceeded, the system triggers a “DANGER – GAS!” alert and buzzer; when readings fall below both thresholds, the buzzer is turned off, status resets to “Normal,” and notification flags are cleared; a virtual button on V2 allows the user to remotely reset alerts and silence the buzzer, and the cycle repeats every second.

Fig. 2. Flowchart of the System.

METHODOLOGY DATA ACQUISITION

The system keeps checking the environment in real time to catch any signs of harmful gases or smoke.

MQ2 Gas Sensor: This sensor can recognize gases like smoke, methane, and LPG. The signal it produces gets powerful as the amount of gas increases. That signal is what the system uses to control whether there is any potential risk.

ESP8266 NodeMCU: The MQ2 sensor’s signal is studied by this microcontroller via its A0 pin. It inspects the data to decide whether the gas level outdo a predetermined threshold.

Real-time data update: To make sure that it is constantly monitoring for gas leaks or smoke accumulation, the system searches the sensor once per second.

While the MQ2 sensor is attached to the ESP8266 NodeMCU, the system can catch gas and smoke in real time and answer fast. The data goes direct to the Blynk app, so users can examine the readings on their phones, acquire alerts, and even reset the system if required.

Data Processing

The sensor will inspect the air, and the ESP8266 grab that reading and action it. If the value exceeds, meaning there’s perhaps smoke or gas, the system gives a caution. It also dispatches the info to your Blynk app so you can inspect it on your phone immediately. That way, you’ll notice when something’s wrong and can do something about it fast.

Threshold Declaration

The system will make use of predefined threshold values to analyze and track environmental circumstances, similar as gas and smoke levels. These thresholds are expository for recognizing risky air quality and stimulate suitable alerts when the levels outdo predefined boundaries. The threshold values are come after:

Gas Threshold (300): A threshold of 300 is explained for the MQ2 sensor to distinguish gas concentration. If the gas concentration exceeds this value, the system recognizes a potential hazard, prompting a warning that designates the existence of a gas leak or risky air quality.

Smoke Threshold (450): A threshold value of 450 is set to recognize smoke concentration. When the smoke level exceeds this threshold, the system recognizes a hazardous smoke concentration and operates the buzzer, specifying a notable safety risk.

These thresholds are anxiously chosen based on general safety guidelines and environmental standards. They make sure that the system can dependably classify environmental hazards such as gas and smoke, giving real-time alerts for user consciousness. Once these thresholds are exceeded, the system dispatches instant notifications via the Blynk app, making sure users get timely warnings to take necessary steps.

Overall AQI Calculation

So primarily, the system observed on the air makes use of the MQ2 gas sensor — it’s the one that raises stuff such as smoke and gas. Now, this sensor throws out a number between 0 and 1023. If the reading stays under 300, that usually means everything’s okay and the air is pretty clean. If it’s somewhere between 300 and 450, the system warns about gas. But if it goes over 450, that usually means there’s smoke, which can be dangerous. This way, the system helps keep an eye on air quality and alerts you fast if there’s a problem.

AQI = (sensorValue ÷ 1023) × 500

Data Transmission and Visualization

The system will transmit and display real-time sensor data both locally through a buzzer and remotely through a mobile application interface.

Blynk Mobile Dashboard: The ESP8266 NodeMCU sends real-time gas concentration values from the MQ2 sensor to the Blynk platform using built-in virtual pins. The value is displayed on the app using Blynk.virtualWrite(V1, sensorValue), allowing users to monitor air quality directly from their smartphones.

Status Display and Alerts: The current condition of the environment is shown via the Blynk interface using virtualWrite (V0, “Status: …”). When gas levels exceed the predefined threshold of 300, the system displays “DANGER – GAS!”; if smoke exceeds the threshold of 450, it updates to “DANGER – SMOKE!”. Otherwise, the system shows “Status: Normal”.

Reset and User Control: A virtual button in the Blynk app (V2) allows users to reset the alarm system. When pressed, it resets both gas and smoke alert flags (gasNotified, smokeNotified) and deactivates the buzzer, allowing for manual acknowledgment of alerts.

Local Buzzer Alert: If the AQI exceeds the set thresholds, the ESP8266 triggers a buzzer connected to pin D5 to provide an audible alert. This ensures immediate on-site notification, especially useful when the mobile device is not nearby.

Data Refresh: The system updates sensor readings every second, ensuring continuous real-time monitoring. Data refresh intervals are controlled via the loop function with a delay (1000).

This setup ensures that users are always informed through both local and remote channels. The integration of IoT-based visualization with Blynk enhances user experience, accessibility, and responsiveness in monitoring hazardous gas or smoke levels.

RESULT

The Smoke and Gas Detection System using ESP8266 and MQ2 sensor was successfully implemented and tested in various indoor conditions. The system achieved reliable real-time monitoring and alerting capabilities using IoT technology. SensorValues were accurately read and evaluated, and the system responded as expected when gas or smoke levels exceeded defined thresholds.

Test Condition Threshold Crossed Alert Triggered
Low ambient air (no smoke/gas) NO NO
Butane gas near sensor Gas threshold (300) DANGER – GAS
Lighter smoke blown on sensor Smoke threshold (450) DANGER – SMOKE

Real-Time Monitoring

The system continuously collects data from the MQ2 gas sensor at 1-second intervals using analogRead. These values are sent to the Blynk platform through virtual pin V1 for real-time display. Monitoring is uninterrupted and provides a consistent stream of environmental data.

AQI Classification

Although the system does not perform a weighted AQI calculation, it classifies air conditions using sensorValue:

sensorValue ≤ 300: Normal

300 <sensorValue ≤ 450: Gas Alert

sensorValue> 450: Smoke Alert

These thresholds are embedded in the firmware and used to determine air quality levels.

Alert Mechanism

When gas or smoke levels exceed the set limits, the system activates a buzzer via D5 for local alerting. Simultaneously, Blynk notifications are sent through virtualWrite and logEvent. Notification flags ensure alerts are only sent once per event, avoiding unnecessary repetition.

Mobile Interface

The Blynk mobile app displays live sensorValues and current status messages through virtual pins. A reset button (V2) allows the user to manually clear alerts and turn off the buzzer. The application provides a responsive and user-friendly associate for remote air quality monitoring.

System Accuracy

Testing showed that the sensor reliably detects gas and smoke concentrations. Thresholds were selected through observation and confirmed to trigger alerts under controlled exposure (e.g., butane, lighter smoke). The system accurately identified hazard levels and responded within one second.

CONCLUSION

This project demonstrates the successful integration of a low-cost, real-time smoke and gas detection system using the MQ2 gas sensor and ESP8266 NodeMCU. The system continuously reads sensorValues and classifies air quality based on predefined thresholds for gas (300) and smoke (450). The solution notifies the user in real time using the Blynk mobile application and sounds a buzzer for instant local alerts when dangerous levels are discovered. The app also lets users reset the system manually, which clears the alert and turns off the buzzer. To avoid sending the same notification over and over, the code uses a flag to control when alerts are triggered. During testing, the system showed it could respond quickly and accurately when gas or smoke was present, with updates happening every second. Overall, it’s a practical and low-cost option for keeping track of air quality indoors. In subsequent developments, the design could be improved by adding more types of gas sensors, showing the data on a small screen nearby, or saving the readings online for later review and analysis.

REFERENCES

  1. Haq, A., Hasan, S. S., Sayed, S., & Ullah, A. (2022). IoT based air quality and weather monitoring system with Android application. In Proceedings of the 2022 International Conference on Computing, Communication, and Intelligent Systems (ICCCIS) (pp. 1–5). IEEE.
  2. Halvorsen, H.-P., Grytten, O. A., Svendsen, M. V., & Mylvaganam, S. (2018). Environmental monitoring with focus on emissions using IoT platform for mobile alert. In 2018 28th EAEEIE Annual Conference (EAEEIE) (pp. 1–7). IEEE.
  3. Hossain, M. A., Islam, M. S., & Hossain, M. S. (2022). Development of a low-cost IoT device using ESP8266 and Atmega328 for real-time monitoring of outdoor air quality with alert. In 2022 International Conference on Robotics, Electrical and Signal Processing Techniques (ICREST) (pp. 1–6). IEEE.
  4. Kayes, A. S. M., Islam, M. R., & Al Islam, A. M. (2020). An IoT-based air quality monitoring platform. In 2020 11th International Conference on Computing, Communication and Networking Technologies (ICCCNT) (pp. 1–7). IEEE.
  5. Kularatna, N., & Sudantha, B. (2008). An environmental air pollution monitoring system based on the IEEE 1451 standard for low-cost requirements. IEEE Sensors Journal, 8(4), 415–422. https://doi.org/10.1109/JSEN.2008.917477
  6. Kwon, J.-W., Park, Y.-M., Koo, S.-J., & Kim, H. (2007). Design of air pollution monitoring system using Zigbee networks for ubiquitous-city. In 2007 International Conference on Convergence Information Technology (ICCIT 2007) (pp. 1024–1031). IEEE.
  7. Rao, V., & Prema, K. (2018). Internet-of-things based smart temperature monitoring system. In 2018 3rd IEEE International Conference on Recent Trends in Electronics, Information and Communication Technology (RTEICT) (pp. 72–77). IEEE.
  8. Raipure, S., & Mehetre, D. (2015). Wireless sensor network-based pollution monitoring system in metropolitan cities. In 2015 International Conference on Communications and Signal Processing (ICCSP) (pp. 1835–1838). IEEE.
  9. Sahoo, S. K., Mohapatra, S. K., & Dash, S. K. (2022). IoT-based industrial air quality monitoring system. In 2022 International Conference on Applied Artificial Intelligence and Computing (ICAAIC) (pp. 234–239). IEEE.
  10. Sonavane, S. S., & Shinde, S. S. (2022). IoT-based smart air pollution monitoring system. In 2022 International Conference on Electronics and Sustainable Communication Systems (ICESC) (pp. 456–461). IEEE.
  11. Yigit, Y., Huseynov, K., Ahmadi, H., & Canberk, B. (2022). YA-DA: YAng-based DAta model for fine-grained IIoT air quality monitoring. arXiv Preprint, arXiv:2211.15287. https://arxiv.org/abs/2211.15287
  12. Al-Ali, A., Zualkernan, I., & Aloul, F. (2010). A mobile GPRS-sensors array for air pollution monitoring. IEEE Sensors Journal, 10(10), 1666–1671. https://doi.org/10.1109/JSEN.2010.2045666

Article Statistics

Track views and downloads to measure the impact and reach of your article.

0

PDF Downloads

183 views

Metrics

PlumX

Altmetrics

Paper Submission Deadline

Track Your Paper

Enter the following details to get the information about your paper

GET OUR MONTHLY NEWSLETTER