Free Tutorial

Arduino-Based Gas Leakage Detection System with Buzzer Alert

Beginner Difficulty
1 Est. Time
5 items Components Needed

About This Project

The Gas Leakage Detection System is a safety project designed to detect the leakage of LPG, methane, propane, and other combustible gases using an MQ-2 Gas Sensor. When the gas concentration exceeds a predefined threshold, the Arduino activates a buzzer to provide a local warning . This system helps prevent accidents in homes, kitchens, laboratories, hotels, and industries by providing an immediate alert.

 

Objectives

  • Detect LPG and combustible gas leakage.
  • Trigger an audible alarm using a buzzer.
  • Display gas level on the Serial Monitor (or optional LCD/OLED).
  • Provide a low-cost safety solution.

 

Components Required

Component Quantity
Arduino Uno 1
MQ-2 Gas Sensor Module 1
Active Buzzer 1
Jumper Wires As required
Breadboard 1

 

Working Principle

  1. The MQ-2 sensor continuously monitors the surrounding air.
  2. The sensor output increases when combustible gas is detected.
  3. The Arduino compares the sensor reading with the threshold.
  4. If the threshold is exceeded:
    • Buzzer sounds continuously
  5. Once the gas level falls below the threshold, the alarm stops and the system returns to monitoring mode.

Components Required

  • Arduino Nano / Uno
  • LCD I2c
  • MQ2
  • Buzzer
  • Wire and Breadboard

Circuit Diagram

Circuit diagram for Arduino-Based Gas Leakage Detection System with Buzzer Alert

Step-by-Step Instructions

  1. Step 1: System Initialization
  2. Step 2: Continuous Gas Monitoring
  3. Step 3: Gas Detection
  4. Step 4: Safe Condition

Source Code

Arduino / ESP32 Sketch
#include <DHT.h>
#include <DHT_U.h>
#include <LiquidCrystal_I2C_Hangul.h>
/*
 * Arduino Sketch for displaying temperature and humidity on a 16x2 I2C LCD.
 * The circuit includes a DHT22 sensor for temperature and humidity readings,
 * and a piezo speaker that rings when the temperature exceeds 40°C. The LCD
 * displays an alert message when the temperature is above 40°C.
 */

#include <Wire.h>
 

#define DHTPIN 8          // Pin connected to the DHT22 data pin
#define DHTTYPE DHT22     // DHT 22 (AM2302)
#define BUZZER_PIN 9      // Pin connected to the piezo speaker

LiquidCrystal_I2C_Hangul lcd(0x27, 16, 2); // Set the LCD address to 0x27 for a 16x2
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  lcd.init();
  lcd.backlight();
  dht.begin();
  pinMode(BUZZER_PIN, OUTPUT);
  digitalWrite(BUZZER_PIN, LOW);
}

void loop() {
  float humidity = dht.readHumidity();
  float temperature = dht.readTemperature();

  if (isnan(humidity) || isnan(temperature)) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Sensor error");
    return;
  }

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Temp: ");
  lcd.print(temperature);
  lcd.print(" C");

  lcd.setCursor(0, 1);
  lcd.print("Hum: ");
  lcd.print(humidity);
  lcd.print(" %");

  if (temperature > 40) {
    digitalWrite(BUZZER_PIN, HIGH);
    lcd.setCursor(0, 1);
    lcd.print("ALERT: High Temp");
  } else {
    digitalWrite(BUZZER_PIN, LOW);
  }

  delay(2000); // Wait 2 seconds before next reading
}

Completed this project?

Get an official Project Completion Certificate with a unique ID & QR verification — perfect for internships, resumes, and college submissions.

Get Certificate →
WhatsApp