Overview

MQ2 and MQ135 gas sensors detect various harmful gases including LPG, methane, carbon monoxide, smoke, and other combustible gases. They're essential for safety systems, air quality monitoring, and fire alarm applications. These sensors provide analog output proportional to gas concentration and are widely used in industrial and residential safety applications.

Technical Specifications

MQ2 vs MQ135 Comparison

Feature MQ2 MQ135
Operating Voltage 5V DC 5V DC
Heater Voltage 5V ± 0.1V 5V ± 0.1V
Heater Current ~150 mA ~150 mA
Detection Range 300-10000ppm 10–1000 ppm
Target Gases LPG, Smoke, Alcohol NH3, NOx, CO2, CO
Preheat Time 20 seconds 20 seconds
Response Time < 10 s < 10 s

Key Features

  • Wide range of detectable gases
  • High sensitivity and fast response
  • Analog output proportional to concentration
  • Digital output with adjustable threshold
  • LED indicator for gas detection status
  • Long lifespan and stability
  • Easy integration with microcontrollers
  • Cost-effective safety solution

Wiring Diagram

Basic Connection (Arduino Uno)

Gas Sensor Pin Arduino Pin
VCC 5V
GND GND
AO (Analog) Analog Pin A0
DO (Digital) Digital Pin 2

Note: Initial burn-in requires 24–48 hours (first use). Typical warm-up before reading: ~20–60 seconds.

Common Applications

Gas Leak Detection

LPG and natural gas leak detection systems

Fire Alarm Systems

Smoke and combustible gas detection

Air Quality Monitoring

Indoor and outdoor air pollution measurement

Industrial Safety

Workplace gas monitoring and safety systems

Quick Info

Difficulty: Intermediate
Price Range: ₹100-300
Interface: Analog/Digital

Sample Code

#define GAS_DIGITAL 2
#define GAS_ANALOG A0
#define BUZZER_PIN 8
#define THRESHOLD 400

void setup() {
  Serial.begin(9600);
  pinMode(GAS_DIGITAL, INPUT);
  pinMode(BUZZER_PIN, OUTPUT);
  
  Serial.println("Gas Sensor Calibrating...");
  delay(20000); // Preheat time
  Serial.println("Gas Sensor Ready");
}

void loop() {
  int digitalValue = digitalRead(GAS_DIGITAL);
  int analogValue = analogRead(GAS_ANALOG);
  
  if (digitalValue == HIGH || analogValue > THRESHOLD) {
    digitalWrite(BUZZER_PIN, HIGH);
    Serial.println("GAS DETECTED! DANGER!");
  } else {
    digitalWrite(BUZZER_PIN, LOW);
    Serial.println("Air Quality: Normal");
  }
  
  Serial.print("Gas Level: ");
  Serial.println(analogValue);
  
  delay(1000);
}