top of page

LPG Gas Leakage Detection System

20 hours ago
3 min read

An LPG Gas Leakage Detection System is designed to detect the presence of LPG or other combustible gases and provide an immediate warning when the gas concentration exceeds a predefined threshold. The system uses an STM32 Nucleo-L031K6 as the main controller and an MQ2 gas sensor to monitor gas levels.


Simulation image showing the working of LPG Gas Leakage Detection System
Simulation image showing the working of LPG Gas Leakage Detection System

When the detected gas level reaches or exceeds the set threshold, the system activates a buzzer alarm and displays a warning on the SSD1306 OLED. The gas value and system status are also displayed through the Serial Monitor, allowing the system to be monitored and tested in real time.


The complete system was designed and tested using the Wokwi simulation environment.


Components Required


S. No.

Component

Quantity

Purpose

1

STM32 Nucleo-L031K6

1

Main controller for processing gas sensor data

2

MQ2 Gas Sensor

1

Detects the presence and level of combustible gas

3

SSD1306 OLED Display

1

Displays the gas value and system status

4

Buzzer

1

Provides an audible warning when gas leakage is detected

5

Jumper Wires

As required

Connects the components to the STM32 board


System Overview and Working Principle


The LPG Gas Leakage Detection System consists of an STM32 Nucleo-L031K6, an MQ2 gas sensor, an SSD1306 OLED display, and a buzzer. The STM32 acts as the main controller and processes the gas-level data received from the MQ2 sensor.


Working Principle

  1. The MQ2 gas sensor measures the surrounding gas level and provides an analog output to the STM32.

  2. The STM32 continuously reads the gas sensor value through its analog input.

  3. A predefined threshold of 700 is used to determine the gas condition.

  4. If the gas value is 700 or higher, the system identifies a gas leakage and activates the buzzer.

  5. If the gas value is below 700, the system considers the condition SAFE and keeps the buzzer OFF.

  6. The gas value and current status are displayed on the SSD1306 OLED and Serial Monitor.


Circuit Connections


Component

Pin

STM32 Nucleo Pin

Purpose

MQ2 Gas Sensor

AOUT

A0

Analog gas-level input

MQ2 Gas Sensor

VCC

3.3V

Power supply

MQ2 Gas Sensor

GND

GND

Ground

SSD1306 OLED

SDA

D4

I²C data

SSD1306 OLED

SCL

D5

I²C clock

SSD1306 OLED

VCC

3.3V

Power supply

SSD1306 OLED

GND

GND

Ground

Buzzer

+

D6

Alarm output

Buzzer

GND

Ground


Programming and Implementation


The system is programmed using the Arduino framework for the STM32 Nucleo-L031K6. The MQ2 sensor is read through the STM32's analog input, while the OLED and buzzer provide the output indications.


5.1 Pin Configuration


The following pins are defined in the program:


  • A0 → MQ2 analog gas input

  • D6 → Buzzer output

  • D4 and D5 → OLED I²C communication

  • 0x3C → OLED I²C address

  • 700 → Gas detection threshold


5.2 Gas Detection


The MQ2 analog value is continuously read and compared with the predefined threshold.


This demonstrates:

  • Reading the MQ2 analog value

  • Comparing it with the 700 threshold

  • Turning the buzzer ON when a leak is detected

  • Turning the buzzer OFF under safe conditions


5.3 OLED Display


The OLED displays the current gas value and status, while the buzzer provides an audible warning during a detected gas-leak condition.


5.4 Source Code



Simulation and Output


The complete LPG Gas Leakage Detection System was simulated in Wokwi to verify the operation of the MQ2 gas sensor, OLED display, and buzzer.


Wokwi simulation output of the LPG Gas Leakage Detection System under a gas-leak condition.
Wokwi simulation output of the LPG Gas Leakage Detection System under a gas-leak condition.


Future Scope


The LPG Gas Leakage Detection System can be further enhanced by:

  • IoT connectivity for remote gas-level monitoring and alerts.

  • Mobile application integration to notify users about gas leakage conditions.

  • Automatic gas shut-off using a solenoid valve to improve safety.

  • Additional gas sensors for detecting different types of combustible gases.

  • SMS or cloud-based alerts for immediate notification during a leakage.

  • Battery backup to maintain operation during power failures


Conclusion


The LPG Gas Leakage Detection System was successfully designed and simulated using the STM32 Nucleo-L031K6, MQ2 gas sensor, SSD1306 OLED display, and buzzer. The system continuously monitors the gas level and compares it with a predefined threshold to identify leakage conditions.


When the gas level exceeds the threshold, the system displays a GAS LEAK DETECTED warning and activates the buzzer. Under safe gas levels, the system displays SAFE and keeps the buzzer OFF. The successful Wokwi simulation confirms that the system performs the intended gas monitoring and alert functions in real time.

 
 
 

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page