Back to Sensors & Actuators Series

Gas Sensor: MQ-2

July 21, 2025 Wasil Zafar 8 min read

MQ-2 deep dive — metal-oxide gas sensing principle, burn-in procedure, PPM calibration, complete code, and real-world alarm applications.

Contents

  1. Working Principle
  2. Electrical Characteristics
  3. Interfacing with MCU
  4. Calibration
  5. Code Example
  6. Real-World Applications
  7. MQ-Series Family
  8. Limitations

Working Principle

The MQ-2 uses a heated tin dioxide (SnO2) semiconductor. In clean air, oxygen adsorbs on the surface, creating a high-resistance depletion layer. When combustible gases (methane, propane, hydrogen, smoke) contact the surface, they react with adsorbed oxygen, releasing electrons and lowering resistance. The resistance change is proportional to gas concentration.

Analogy: Imagine a sponge (SnO2) that soaks up oxygen and swells (high resistance). Gas molecules squeeze the oxygen out, making the sponge shrink (low resistance).

Electrical Characteristics

ParameterValue
Heater Voltage5 V ± 0.1 V
Heater Current~150 mA
Detectable GasesLPG, methane, propane, hydrogen, smoke
PPM Range200 – 10,000 ppm
Warm-up Time> 24 hours (full), > 2 min (functional)
OutputAnalog (voltage divider) + digital (comparator threshold)

Calibration & PPM Calculation

The key calibration value is R0 — the sensor resistance in clean air. Measure it after the sensor has warmed up for 24+ hours:

R_s = R_load * (V_cc - V_out) / V_out

R_0 = R_s / 9.8 (clean air ratio from datasheet)

Code Example

/*
 * MQ-2 Gas Sensor — Arduino
 * Wiring: A0 → Analog out, VCC → 5V, GND → GND
 * IMPORTANT: Allow 2+ min warm-up before trusting readings
 */
#define MQ2_PIN   A0
#define R_LOAD    10000.0   /* 10kΩ load resistor on module */
#define R0_CLEAN  9.8       /* Rs/R0 ratio in clean air */

float R0 = 10000.0;  /* Will be calibrated */

float readRs() {
    int adc = analogRead(MQ2_PIN);
    float voltage = adc * (5.0 / 1023.0);
    if (voltage < 0.01) voltage = 0.01;  /* Prevent divide-by-zero */
    return R_LOAD * (5.0 - voltage) / voltage;
}

void calibrate() {
    Serial.println("Calibrating in clean air...");
    float rsSum = 0;
    for (int i = 0; i < 50; i++) {
        rsSum += readRs();
        delay(100);
    }
    R0 = (rsSum / 50.0) / R0_CLEAN;
    Serial.print("R0 = "); Serial.println(R0);
}

void setup() {
    Serial.begin(9600);
    delay(3000);   /* Warm-up delay */
    calibrate();
}

void loop() {
    float rs = readRs();
    float ratio = rs / R0;

    /* Approximate LPG ppm from datasheet curve (log-log) */
    float ppm = pow(10, ((log10(ratio) - 0.26) / -0.47) + 2.3);

    Serial.print("Rs/R0: "); Serial.print(ratio, 2);
    Serial.print(" | ~PPM: "); Serial.println(ppm, 0);

    if (ratio < 2.0) {
        Serial.println("⚠ WARNING: Elevated gas level detected!");
    }
    delay(1000);
}
Safety Warning: MQ-series sensors are not safety-rated gas detectors. Never rely on them as sole protection against toxic or explosive gas exposure. Use certified detectors (e.g., UL/CSA listed) for life-safety applications.

MQ-Series Gas Sensor Family

The MQ series shares the same SnO&sub2; MOX architecture but with different doping and heater profiles tuned for specific gases. All use the same load-resistor + heater circuit:

ModelTarget GasRangeUse Case
MQ-2LPG, Methane, Smoke300–10,000 ppmKitchen gas leak alarm
MQ-3Alcohol (ethanol)25–500 ppmBreathalyser / BAC
MQ-4Methane (CH&sub4;)200–10,000 ppmNatural gas pipelines
MQ-5LPG, Natural gas200–10,000 ppmGas stove leak detection
MQ-6LPG, Butane200–10,000 ppmButane torch/LPG cylinders
MQ-7Carbon monoxide (CO)20–2,000 ppmCO safety alarm
MQ-8Hydrogen (H&sub2;)100–10,000 ppmFuel cell / battery labs
MQ-9CO + Combustible gas10–10,000 ppmMulti-gas alarm
MQ-135NH&sub3;, Benzene, CO&sub2;, VOCs10–1,000 ppmIndoor air quality
Choosing an MQ sensor: MQ-7 is essential for any CO safety project (silent killer gas). MQ-135 is best for general indoor air quality. MQ-3 is the go-to for alcohol/BAC estimation. All share the same heater circuit — swap the load-resistor calibration and code for the target sensor.

Limitations

  • Cross-sensitivity: Cannot distinguish between gases; LPG and methane produce similar responses. Use dedicated sensors (MQ-7 for CO, MQ-3 for alcohol) to reduce ambiguity.
  • Power hungry: 150 mA heater makes it unsuitable for battery-powered devices.
  • Long burn-in: 24+ hours needed for stable R0; casual use gives wildly inaccurate PPM values.
  • Not calibrated: All MQ sensors ship uncalibrated; each unit needs individual R0 measurement in clean air.