Why MQ-5?

The sensor is sensitive to LPG, methane, and propane and strikes a good balance between sensitivity and stability for typical LPG usage, making it a perfect fit for this Arduino Project

How It Works

1. The MQ-5 sensor always monitors the air quality.

2. When gas concentration goes above a set level, it outputs LOW.

3. The Arduino reads this and triggers a buzzer and an LED.

Once the gas concentration drops, everything resets.

Tuning is done through a trimpot on the MQ-5.

Circuit Overview

MQ-5 digital output → Arduino A2 

Buzzer → A0 (optional 10k resistor inline to adjust volume) 

LED → A1 (with 220Ω resistor) 

Powered via USB or 9V battery to Vin 

You’ll also need a breadboard and some jumper wires to get going.

Code

const int gasSensorDigitalPin = A2; // MQ-5 sensor digital output connected to A2
const int ledPin = A1;              // LED connected to A1 (through 220Ω resistor)
const int buzzerPin = A0;           // Buzzer connected to A0 (through 1KΩ resistor)

void setup() {
  // Set up pin modes
  pinMode(gasSensorDigitalPin, INPUT);  // MQ-5 sensor as input
  pinMode(ledPin, OUTPUT);              // LED as output
  pinMode(buzzerPin, OUTPUT);           // Buzzer as output

  // Start Serial Monitor
  Serial.begin(9600);
  Serial.println("Gas Detection System Initialized (Digital Mode)");
}

void loop() {
  // Read the sensor's digital output
  int gasState = digitalRead(gasSensorDigitalPin);  // LOW = Gas detected

  // Check if gas is detected
  if (gasState == LOW) {
    digitalWrite(ledPin, HIGH);     // Turn on LED
    digitalWrite(buzzerPin, HIGH);  // Turn on Buzzer
    Serial.println("!! Gas Leak Detected !!");
  } else {
    digitalWrite(ledPin, LOW);      // Turn off LED
    digitalWrite(buzzerPin, LOW);   // Turn off Buzzer
    Serial.println("Environment Normal");
  }

  delay(800);  // Delay to avoid flooding Serial Monitor
}

No libraries or complications, just clean logic.

Testing and Tuning

To simulate a leak, use a butane lighter (unlit). The potentiometer on the MQ-5 has to be adjusted until the alarm can reliably trigger in its presence(the system should stay silent otherwise).

If sensitivity is too much, keep tweaking the potentiometer.

Tip: Let the sensor warm up for 24 hours before tuning for accurate results.

Expandability

Once you have the basics covered.

  • You can add SMS alerts via GSM modules
  • Connect it to the cloud via ESP8266/ESP32
  • Log gas levels over time
  • Integration with a smart home system. 

For a comprehensive guide, visit: https://circuitdigest.com/microcontroller-projects/gas-leakage-detector-using-arduino-complete-diy-guide