1. Introduction
Liquefied Petroleum Gas (LPG) is one of the most widely used energy sources for domestic purposes worldwide, primarily for cooking, water heating, and space heating. Its popularity stems from its energy efficiency, affordability, and ease of storage and transport. According to the International Energy Agency (IEA), over 2.3 billion people rely on LPG for household use [
1]. However, its domestic use poses significant safety risks when not accompanied by proper monitoring and control systems, potentially leading to poisoning, fires, or explosions.
In Ecuador, 92% of households use LPG as their primary energy source [
2]. This heavy reliance has resulted in numerous incidents related to gas leaks and explosions. In 2022 alone, Quito’s Fire Department reported over 200 emergencies involving gas leaks [
3]. Despite this, most homes lack early detection systems or automatic shut-off mechanisms, increasing the risk of severe accidents.
LPG leaks are often caused by faulty valves, deteriorated cylinders, or poor connections [
4]. Without early detection, gas can accumulate, creating highly dangerous conditions. Most households do not have sensors to detect hazardous levels, nor automated systems to cut off gas supply, which delays effective responses and increases vulnerability [
5]. This issue is further exacerbated by a limited culture of preventive maintenance and the infrequent technical inspection of gas components [
5].
This situation reveals a critical gap between the widespread domestic use of LPG and the lack of affordable, reliable systems for its safe management. Although various technologies for gas leak detection exist, their adoption in homes remains limited due to cost, complexity, or lack of awareness. There is a clear need for comprehensive, accessible solutions that enable continuous monitoring, real-time alerts, and automatic shut-off responses.
Recent research has increasingly turned to Internet of Things (IoT)-based technologies to address domestic safety concerns. As electronic components become more affordable and development platforms more accessible, IoT applications for real-time emergency detection are becoming viable in low-resource settings. For example, Chérrez developed an IoT-based LPG leak detection system using the MQ-2 sensor and NodeMCU ESP8266, capable of sending real-time alerts via sound and WhatsApp [
5]. In India, Jagadish and Sonam designed a system using MQ-6 sensors, GSM modules, and automated shut-off mechanisms, integrated with ThingSpeak for real-time gas level visualization [
6].
Barajas and Monroy developed a mobile robotic platform for LPG detection with GPS and a camera, demonstrating effective real-time navigation and gas monitoring capabilities [
7]. Camargo and Alarcón proposed a vision-based gas level monitoring system using an ESP32-CAM to read analog gauges and provide web-based visualization [
8]. Murty and Dhanikonda, as well as Niveditha and Harshini, developed low-cost IoT-based LPG leak detection systems with GSM alerting and automatic shut-off valves, aimed at both domestic and industrial environments [
9,
10].
These studies reflect a trend toward developing accessible, reliable, and real-time safety solutions using IoT technologies. Building on this foundation, the present research proposes an integrated IoT-based system for detecting and monitoring LPG leaks in domestic environments, combining early detection, automatic valve shut-off, and real-time user alerts [
11].
Liquefied Petroleum Gas (LPG) detection relies primarily on semiconductor gas sensors, such as the MQ series, which operate by measuring changes in the resistance of a sensitive layer when exposed to combustible gases. Among these, the MQ-5 sensor demonstrates high sensitivity to LPG, making it suitable for continuous domestic monitoring. To process sensor data and enable system connectivity, the ESP32 microcontroller was selected due to its low power consumption, integrated Wi-Fi and Bluetooth modules, and dual-core processing capacity, which allow both sensing and communication tasks to be performed efficiently on a single device. For data transmission, the MQTT (Message Queuing Telemetry Transport) protocol was adopted, as it provides lightweight, low-latency communication optimized for IoT applications, ensuring reliable message delivery and scalability in distributed monitoring systems. Together, these components establish a cost-effective, real-time, and adaptable technical foundation for the proposed detection and control solution.
The paper is organized as follows.
Section 2 describes the materials and methodology used to develop the proposed IoT-based system [
12].
Section 3 presents experimental results and system performance analysis. Finally,
Section 4 offers conclusions and outlines future work.
2. Materials and Methods
This research adopted an applied, experimental, and documentary methodology to develop a technological solution focused on domestic safety using IoT devices. The project centered on the design and implementation of a functional system capable of detecting hazardous concentrations of LPG, triggering automatic valve shut-off mechanisms, and issuing real-time alerts through connected platforms.
In the documentary phase, an extensive review of scientific literature, academic theses, technical articles, user manuals, and current Ecuadorian regulations regarding LPG installation and safety was conducted. This review provided the theoretical foundation for the system, identified relevant precedents, and informed the technical criteria for its design and implementation.
The experimental approach was essential for evaluating the prototype’s performance under controlled conditions that simulated real-world domestic scenarios. Multiple tests were conducted using MQ gas sensors (models MQ-5, MQ-6, and MQ-135), measuring key variables such as detection time, valve shut-off activation, and alert transmission. These tests were performed in a local setup using a Raspberry Pi-hosted server and later migrated to a cloud-based infrastructure, allowing the system to be validated under varying connectivity conditions [
13].
To support the analysis, appropriate methods and instruments were employed for collecting technical and functional data, including system behavior logs, direct observation, and response analysis of both hardware and software components. This methodological combination enabled a comprehensive approach to the problem, resulting in practical, replicable outcomes with direct application in residential environments that rely on LPG.
2.1. Flow Diagram
For the development of the Liquefied Petroleum Gas (LPG) leak detection and control system, the Rapid IoT Prototyping methodology is applied, as it structures the work into practical phases that directly address the prototype’s requirements. This methodology facilitates the progressive implementation, testing, and integration of each component. The system incorporates an MQ-5 gas sensor to detect LPG concentration in the environment, an ESP32 microcontroller programmed to interpret the sensor’s signals and transmit the data using the MQTT protocol [
14], and a server that stores this data in a database. Real-time visualization is achieved through Grafana, and alerts are automatically sent to the user via Telegram. A servo motor controls the valve closure when a critical condition is detected. Thanks to the iterative nature of the methodology, each module is validated individually before full system integration, ensuring proper operation under controlled conditions.
The flowchart shown in
Figure 1 represents the system’s logical behavior, from initial gas reading to the automatic activation of response mechanisms. The MQ-5 sensor continuously monitors the LPG concentration, and the ESP32 sends the detected values to the server via MQTT. Suppose the system identifies that the concentration exceeds 2000 parts per million (ppm). In that case, the valve is closed via the servo motor, and an immediate alert is sent to the user through Telegram. The 2000 ppm threshold is defined based on tests performed directly on the prototype, where gas leaks were simulated using open lighters. These tests show that values above this range represent a real hazard. This decision is also supported by the EN 60079-29-1 standard, which states that sensors must generate alerts before reaching the Lower Explosive Limit (LEL) [
15].
2.2. Local Server on Raspberry Pi
Initially, the server was deployed using a Raspberry Pi 4, where the database service (MariaDB V11.8.2), MQTT broker (Mosquitto V3.1), and visualization tools (Grafana V12.0.0 and PHPMyAdmin V5.2.2) were installed. The established architecture is shown in
Figure 2. Each node is connected via an ESP32, which contains an MQ-5 gas sensor. In this network, a Raspberry Pi4 acts as a server using Mosquito (MQTT broker), with phpMyAdmin managing storage and Grafana managing panel visualization. The broker-centric design decouples acquisition from storage and visualization, allowing end-to-end verification of the data flow within the internal network. When remote access is required, authenticated clients can securely access the Raspberry Pi4 services using ZeroTier without the need to open the local network [
16,
17,
18].
2.3. Update with Cloud-Based Server
Access from the internet is via a cloud (Google Cloud), which centralizes the backend without requiring additional infrastructure in the remote nodes [
19,
20,
21].
Figure 3 shows that each prototype connects via a local Wi-Fi network and sends telemetry to the cloud via MQTT. The cloud hosts services such as the Mosquitto broker for message transport, MySQL for storage, and Grafana for visualization. This architecture enables a secure and stable communication channel, allowing for scalability, and customers can access data queries in real time.
3. Results
3.1. Communication Latency and Data Logging
This test aimed to evaluate the delay between the MQ-5 sensor reading a gas concentration value and its storage in the database. The analysis focused on determining the efficiency of communication between the ESP32 microcontroller, the MQTT protocol, and the Python V3.13 script responsible for inserting the data into MySQL V8.1. To perform the test, the ESP32 was connected to the computer via the serial port, and the Arduino serial monitor was used to log the reading time. Simultaneously, the Python service stored the data with its corresponding timestamp. The comparison between both timestamps allowed for the calculation of the delay time and validation of the system’s responsiveness. Subsequently, both timestamps were extracted and compared to calculate the time interval representing the delay of the communication system. This information was organized and systematized in
Table 1, which allows observing the delay values across different iterations of the system.
Figure 4 shows alert messages sent to Telegram show the notifications delivered to the user via Telegram after the detection of a critical gas concentration, followed by a status update indicating that values have returned to normal levels.
3.2. System Availability
To evaluate the availability of the IoT system under continuous operational conditions, a test was conducted based on the analysis of a 24-hour time window. During this period, 8640 records were expected per prototype, considering a sampling rate of one data point every 10 s. Through queries to the MySQL database, the actual number of records stored by each device was verified. These results, presented in
Figure 5, show the database record, which enabled the calculation of the individual availability of each system. This data reflects the system’s efficiency in continuously transmitting and storing data, taking into account factors such as connectivity, MQTT broker stability, and service performance.
Using Equation (1), the number of expected data points over 24 h with a sampling interval of 10 s is determined to be 8640.
To calculate service availability, Equation (2) is used. The results are shown in
Figure 5.
Through the device availability tests, it was determined that the system has an average service availability of 89.48%. The prototype installed on the LPG cylinder is shown in
Figure 6.
Systems based on NodeMCU ESP8266 and GSM modules typically have response times over 5 s and lack cloud-based monitoring, while robotic or vision-based platforms offer effective detection at higher cost and complexity. In contrast, our system provides low latency, high availability, and affordability, highlighting its contribution to improving IoT-based LPG detection solutions. As shown in
Table 2.
4. Conclusions
The system was successfully designed by integrating a functional architecture based on the MQ-5 sensor and the ESP32 microcontroller, components that enabled accurate and timely detection of hazardous LPG concentrations in domestic environments. The selection of these elements, along with the definition of critical thresholds, ensured early gas identification, fulfilling the design objective focused on preventive safety.
An automatic valve shut-off mechanism was effectively implemented using IoT technology, allowing immediate response upon detecting critical conditions. The ESP32-controlled servomotor precisely executed corrective action without human intervention, demonstrating the system’s ability to contain gas propagation and mitigate domestic accident risks.
Functional and performance tests showed that the system operates effectively, efficiently, and reliably. Response times of under 2 s were verified from detection to data storage and visualization, along with adequate service availability. This successful integration of sensing, communication, storage, monitoring, and alerting validates the system as a technologically viable and replicable solution for mitigating LPG-related risks.
It is recommended to incorporate an uninterruptible power supply (UPS) system—such as rechargeable batteries or dedicated UPS modules—to ensure continuous operation of the detection and control system, especially during power outages. This enhancement is crucial to guarantee valve shut-off activation and alert delivery even under emergency conditions.
It is also advised to integrate redundancy in sensing and communication nodes by using multiple sensors in parallel or duplicating data transmission paths. This strategy would enable critical reading verification by consensus, reduce the likelihood of failures due to disconnection or isolated component errors, and enhance the overall system reliability.
Additionally, improving the MQTT data transmission system is proposed by implementing automatic retry mechanisms and local handling of unsent packets. This optimization would increase system availability beyond 95%, minimize data loss during temporary disconnections, and ensure higher integrity in logging into critical events.
As part of future developments, the system could be enhanced through the integration of renewable power supplies (e.g., solar panels or rechargeable batteries) to guarantee autonomy during prolonged power outages. Another promising direction is the deployment of redundancy in sensing nodes, combined with machine learning algorithms, to predict failures and optimize leak detection accuracy. Moreover, scaling the architecture to industrial environments and integrating the platform with smart home ecosystems would broaden its applicability and impact.
Author Contributions
Conceptualization, E.F.R.P.; methodology, A.L., E.F.R.P. and F.T.; formal analysis, L.A.F.; investigation, L.A.F., A.L. and F.L.; resources, L.A.F., L.O.F. and E.F.R.P.; data curation, E.F.R.P. and L.O.F.; writing—original draft, L.A.F., F.T. and F.L.; writing—review and editing, E.F.R.P., L.O.F. and L.A.F.; visualization, F.L. and F.T.; supervision, E.F.R.P. and L.A.F.; project administration, E.F.R.P. and F.T.; funding acquisition, E.F.R.P. All authors have read and agreed to the published version of the manuscript.
Funding
This research received no external funding.
Institutional Review Board Statement
Not applicable.
Informed Consent Statement
Not applicable.
Data Availability Statement
No new data were created or analyzed in this study. Data sharing is not applicable to this article.
Acknowledgments
The authors appreciate the sponsorship of the Universidad Técnica de Ambato in carrying out this research work.
Conflicts of Interest
The authors declare no conflicts of interest.
References
- International Energy Agency. LPG: A Cleaner Energy Solution for Cooking. Paris. 2020. Available online: https://www.iea.org/reports/a-vision-for-clean-cooking-access-for-all (accessed on 1 April 2025).
- Instituto Nacional de Estadística y Censos. Encuesta Nacional de Ingresos y Gastos de los Hogares Urbanos y Rurales. Quito. 2020. Available online: https://www.ecuadorencifras.gob.ec (accessed on 1 April 2025).
- Cuerpo de Bomberos del Distrito Metropolitano de Quito. Informe de Rendición de Cuentas 2021. Quito. 2022. Available online: https://www.bomberosquito.gob.ec/images/pdf/cuentas/informerc21.pdf (accessed on 1 April 2025).
- Hernández Granda, K.D.; Quishpe Rivera, L.F. Autonomous Security System for Detection of LPG Gas Leaks in a Residential Area. Bachelor’s Thesis, Electronics and Automation, Universidad Politécnica Salesiana, Quito, Ecuador, March 2023. Available online: http://dspace.ups.edu.ec/handle/123456789/24503 (accessed on 1 April 2025).
- Chérrez, P.; Campoverde, M. Development of an IoT prototype for domestic gas leak detection. Dominio Cienc. 2022, 8, 963–979. [Google Scholar] [CrossRef]
- Nuga, O.O.; Amusa, K.A.; Olanipekun, A.J. GSM-Based Gas Leakage Detection and Alert System. ABUAD J. Eng. Res. Dev. (AJERD) 2017, 1, 100–104. [Google Scholar]
- Barajas Cortes, Á.J. Mobile robotic platform IoT-based for LP gas detection. In Proceedings of the LACCEI International Multi-Conference for Engineering, Education and Technology, Latin American and Caribbean Consortium of Engineering Institutions, Buenos Aires, Argentina, 19–21 July 2023. [Google Scholar] [CrossRef]
- Camargo Burgos, E.C.; Alarcón Paredes, A.; Alonso Silverio, G.A. Un dispositivo IoT de fácil acoplamiento para la supervisión de la presión del gas LP. XIKUA Boletín Científico Esc. Super. Tlahuelilpan 2024, 12, 57–64. [Google Scholar] [CrossRef]
- Sreerama Murty, M.; Rao Dhanikonda, S.; Sowjanya, P.; Jagdish Kumar, P.; Chandra, N.S.; Dastagiraiah, C. Smart Gas Leakage Detector Using IoT Sensors. Available online: https://www.ijisae.org (accessed on 24 March 2024).
- Niveditha, N.; Harshini, B.; Peria Mahalakshmi, M. Smart Gas Leakage Detection Using IOT. Int. Res. J. Adv. Eng. Hub (IRJAEH) 2025, 3, 687–692. [Google Scholar] [CrossRef]
- Reyes Quimí, C.; Arguello Morejón, A.G. Design and Feasibility Analysis of an LPG Distribution Network for a Condominium. Integrative Project, Faculty of Mechanical Engineering and Production Sciences, Escuela Superior Politécnica del Litoral, Guayaquil, Ecuador. 2023. Available online: https://dspace.espol.edu.ec/handle/123456789/60814 (accessed on 29 September 2025).
- Al-Fuqaha, A.; Guizani, M. Internet of Things: A Survey on Enabling Technologies, Protocols, and Application. IEEE Communication Surveys & Tutorials. Available online: https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=7123563 (accessed on 22 June 2025).
- Li, M.; Yu, F.R.; Si, P.; Zhang, Y. Energy-Efficient Machine-to-Machine (M2M) Communications in Virtualized Cellular Networks with Mobile Edge Computing (MEC). IEEE Trans. Mob. Comput. 2019, 18, 1541–1555. [Google Scholar] [CrossRef]
- Aleesha, M.; Laseena, C.A. MQTT Protocol for Resource Constrained IoT Applications: A Review. SSRN Electron. J. 2022. [Google Scholar] [CrossRef]
- Djordjevic, V. Data-driven control of hydraulic servo actuator based on adaptive dynamic programming. Discret. Contin. Dyn. Syst.-S 2022, 15, 1633–1650. [Google Scholar] [CrossRef]
- Bormann, C.; Castellani, A.P.; Shelby, Z. CoAP: An application protocol for billions of tiny internet nodes. IEEE Internet Comput. 2012, 16, 62–67. [Google Scholar] [CrossRef]
- An, Y.; Yu, F.R.; Li, J.; Chen, J.; Leung, V.C.M. Edge Intelligence (EI)—Enabled HTTP Anomaly Detection Framework for the Internet of Things (IoT). IEEE Internet Things J. 2021, 8, 3554–3566. [Google Scholar] [CrossRef]
- Naik, N. Choice of effective messaging protocols for IoT systems: MQTT, CoAP, AMQP and HTTP. In Proceedings of the 2017 IEEE International Symposium on Systems Engineering, ISSE, Vienna, Austria, 11–13 October 2017. [Google Scholar] [CrossRef]
- Gupta, P.; Indhra, M. A Survey of Application Layer Protocols for Internet of Things. In Proceedings of the International Conference on Communication, Information and Computing Technology, ICCICT 2021, Mumbai, India, 25–27 June 2021. [Google Scholar] [CrossRef]
- Flores, L.A.; Lomas, I.; Guachalá, L.; Lupera-Morillo, P.; Álvarez, R.; Llugsi, R. Direction-of-Arrival (DOA) Estimation Based on Real Field Measurements and Modified Linear Regression. Eng. Proc. 2024, 77, 11. [Google Scholar] [CrossRef]
- Hosny, K.M.; Magdi, A.; Salah, A.; El-Komy, O.; Lashin, N.A. Internet of things applications using Raspberry-Pi: A survey. Int. J. Electr. Comput. Eng. (IJECE) 2023, 13, 902–910. [Google Scholar] [CrossRef]
| Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).