MQ2 with Arduino UNO

Gas leakage and smoke detection systems are important safety devices for homes, laboratories, kitchens, and workshops. In this project, we build a simple and affordable gas leakage alarm using an Arduino Arduino Uno, an MQ-2 gas sensor, and a buzzer.

The MQ-2 sensor can detect gases like LPG, methane, propane, hydrogen, and smoke. When the sensor detects gas above a certain threshold, the Arduino activates a buzzer to alert nearby people.

This project is beginner-friendly and a great introduction to sensors and safety systems.

Components Required

Component Quantity
Arduino Uno 1
MQ-2 Gas Sensor 1
Active Buzzer 1
Jumper Wires Few
Breadboard (optional) 1

How the MQ-2 Sensor Works

The MQ-2 sensor contains a sensitive material that changes resistance when exposed to combustible gases or smoke.

The sensor provides:

  • Analog Output (AO) → Gas concentration value
  • Digital Output (DO) → HIGH/LOW trigger output

In this project, we use the analog output for better sensitivity control.

Circuit Diagram

Circuit Connections

MQ-2 Pin Arduino Pin
VCC 5V
GND GND
AO A0
Buzzer Pin Arduino Pin
Positive (+) D8
Negative (-) GND

Arduino Program

#define MQ2_PIN A0
#define BUZZER 13

/* Your code... */

int threshold = 400;

void setup() {

pinMode(BUZZER, OUTPUT);
digitalWrite(BUZZER, LOW);

Serial.begin(9600);
}

void loop() {

int gasValue = analogRead(MQ2_PIN);

Serial.print("Gas Value: ");
Serial.println(gasValue);

if (gasValue > threshold) {

digitalWrite(BUZZER, HIGH);

} else {

digitalWrite(BUZZER, LOW);

}

delay(200);
}

Leave a Reply

Your email address will not be published. Required fields are marked *