Documentation

ShillehTek MQ-2 Flammable Gas & Smoke Sensor Module for Arduino Safety | ShillehTek Product Manual
Documentation / ShillehTek MQ-2 Flammable Gas & Smoke Sensor Module for Arduino Safety | ShillehTek Product Manual

ShillehTek MQ-2 Flammable Gas & Smoke Sensor Module for Arduino Safety | ShillehTek Product Manual

shillehtek

Overview

The MQ-2 is a metal-oxide gas sensor that responds to flammable and combustible gases — LPG, propane, methane, hydrogen, alcohol, and smoke. It's the workhorse sensor for DIY smoke detectors, leak alarms for gas appliances, robot kitchen monitors, and any safety-oriented hobby project that needs to know "is something burning or leaking nearby?".

The breakout board includes the MQ-2 sensing element, a sensitivity-adjustment trim pot, an LM393 comparator, a power LED, and a digital-output indicator LED. The analog output (AO) gives you a continuous gas concentration reading; the digital output (DO) goes LOW when the level crosses the threshold set by the on-board pot. Wire it to any microcontroller with an analog input.

Like all MQ-series sensors, the MQ-2 has an internal heater that needs to warm up before readings stabilize: about 24-48 hours on first use, then 1-3 minutes any time you re-power.

At a Glance

Detects
LPG, methane, smoke, H2, alcohol
Operating Voltage
5V DC
Heater Current
~150 mA
Outputs
Analog + Digital
Detection Range
300 - 10000 ppm
Pins
VCC, GND, AO, DO

Specifications

Parameter Value
Sensing Element MQ-2 (SnO2 metal-oxide semiconductor)
Operating Voltage 5V DC
Heater Voltage 5V +/- 0.1V
Heater Power ~800 mW
Heater Current ~150 mA
Detected Gases LPG, propane, butane, methane, H2, alcohol, smoke
Detection Range 300 - 10000 ppm (gas-dependent)
Analog Output (AO) 0 - VCC, increases with gas concentration
Digital Output (DO) HIGH normally, LOW above pot threshold
Comparator LM393, threshold via on-board pot
Initial Warm-up 24-48 hours (first use)
Re-warm-up 1-3 minutes
Operating Temperature -20 degC to +50 degC
Dimensions ~32 x 22 mm

Pinout Diagram

MQ-2 flammable gas and smoke sensor module pinout diagram showing VCC (5V), GND, Digital Out (DO threshold), Analog Out (AO), sensitivity adjust trim pot, voltage comparator IC (LM393), and the MQ-2 sensing element

Wiring Guide

Arduino Wiring

The MQ-2 needs a stable 5V supply because the heater pulls roughly 150 mA. A USB-powered Arduino works for one MQ sensor; for multiple sensors use an external 5V supply.

MQ-2 Pin Arduino Pin
VCC 5V
GND GND
AO A0 (analog input)
DO D2 (digital input, optional)
Tip: The metal cap of the MQ-2 gets warm during operation — this is the heater doing its job. Keep the sensor away from anything heat-sensitive and don't enclose it in a sealed box; it needs gas exchange with the air around it.

ESP32 Wiring

Power the heater from VIN (5V). The analog output can swing close to 5V at high concentrations, so use a 2:1 voltage divider before the ADC pin to stay in the 0-3.3V safe range.

MQ-2 Pin ESP32 Pin Details
VCC VIN (5V) Heater needs full 5V
GND GND
AO GPIO 34 Through 2:1 divider
DO GPIO 35 3.3V logic; safe direct
Warning: AO can rise above 3.3V at high gas concentrations. Connect it to the ESP32 through a divider (two 10k resistors in series, output taken from the middle node). Without the divider you risk damaging the ADC pin.

Raspberry Pi Wiring

The Pi has no analog input. Read AO through an external ADC like the ADS1115 over I2C; DO can connect to a regular GPIO directly.

Connection Pi / ADC
MQ-2 VCC Pin 2 (5V)
MQ-2 GND Pin 6 (GND)
MQ-2 AO ADS1115 A0
MQ-2 DO Pin 11 (GPIO 17)
ADS1115 SDA Pin 3 (GPIO 2)
ADS1115 SCL Pin 5 (GPIO 3)
Info: The MQ-2's AO can swing close to 5V at high gas concentrations. The ADS1115 with its +/-6.144V range handles this without an external divider. Just remember to share the GND between the Pi, the ADS1115, and the MQ-2.

Raspberry Pi Pico Wiring

The Pico's 12-bit ADC reads up to 3.3V. Power the heater from VBUS (5V) and use a 2:1 divider on AO before the GPIO ADC pin.

MQ-2 Pin Pico Pin Details
VCC VBUS (5V from USB)
GND GND
AO GP26 (ADC0) Through 2:1 divider
DO GP15

Code Examples

Arduino - Smoke / Gas Alarm

mq2_arduino.ino
// MQ-2 - Print analog reading and trigger a buzzer if smoke/gas detected

const int aoPin   = A0;
const int doPin   = 2;
const int buzzer  = 8;

const int ALARM_THRESHOLD = 400;  // tune to your environment

void setup() {
  Serial.begin(9600);
  pinMode(doPin, INPUT);
  pinMode(buzzer, OUTPUT);
  Serial.println("MQ-2 warming up - wait 1-3 minutes for stable values");
}

void loop() {
  int raw = analogRead(aoPin);
  bool digitalAlarm = (digitalRead(doPin) == LOW);

  Serial.print("Raw="); Serial.print(raw);
  if (raw > ALARM_THRESHOLD || digitalAlarm) {
    Serial.print("  [ALARM]");
    tone(buzzer, 1000, 200);
  }
  Serial.println();
  delay(500);
}

ESP32 - Read Concentration in Volts

mq2_esp32.ino
// MQ-2 on ESP32 - read AO through a 2:1 divider

const int   aoPin   = 34;
const float VREF    = 3.3;
const float DIVIDER = 0.5;

void setup() {
  Serial.begin(115200);
  analogReadResolution(12);
}

void loop() {
  int raw = analogRead(aoPin);
  float vAtPin = raw * VREF / 4095.0;
  float vReal  = vAtPin / DIVIDER;
  Serial.printf("Raw=%4d  Vpin=%.3f  Vreal=%.3f V\n", raw, vAtPin, vReal);
  delay(500);
}

Raspberry Pi Pico - MicroPython

mq2_pico.py
# MQ-2 on Raspberry Pi Pico (MicroPython)
# AO -> 2:1 divider -> GP26 (ADC0); DO -> GP15

from machine import ADC, Pin
import time

ao = ADC(26)
do = Pin(15, Pin.IN)

print("Warming up MQ-2 - wait 1-3 minutes for stable values")

while True:
    raw = ao.read_u16()
    v_pin  = raw * 3.3 / 65535
    v_real = v_pin * 2
    alarm  = " ALARM" if do.value() == 0 else ""
    print("Raw={:5d}  Vreal={:.2f} V{}".format(raw, v_real, alarm))
    time.sleep(0.5)

Frequently Asked Questions

Can I rely on the MQ-2 as a household smoke alarm?
No. The MQ-2 is a hobbyist sensor — it works, but it lacks the certifications, low-battery alerts, audible 85 dB siren, and tamper-resistant housing of a UL-listed smoke detector. Use a certified detector for life safety; use the MQ-2 for projects, alerts, and learning.
Why are my readings unstable for the first day?
All MQ-series sensors need 24-48 hours of continuous power to "burn in" the metal-oxide layer. After that, expect 1-3 minutes of stabilization any time you re-power. Skipping burn-in produces drift and false readings.
What does the on-board pot do?
It sets the threshold for the digital DO output. When AO rises above the pot setting, the LM393 comparator pulls DO LOW and lights the indicator LED. Turn clockwise to raise the threshold (less sensitive); counter-clockwise to lower it (more sensitive).
My Arduino restarts when I plug in the MQ-2. Why?
The heater inrush current can sag the 5V rail enough to reset a USB-powered Arduino. Use a powered USB hub or external 5V supply, and add a 100 uF cap close to the sensor's VCC pin to absorb the spike.
How sensitive is the MQ-2 to specific gases?
It responds most strongly to LPG, propane, butane, hydrogen, methane, alcohol, and smoke — roughly in that order. It does not selectively identify one gas; the AO output is a generic "combustible content of the air" signal. For more specific detection, look at MQ-7 (CO), MQ-3 (alcohol), or MQ-9 (CO + methane).
Can I run this from a battery?
Continuously, no — the heater drains a typical 18650 cell in under a day. You can put the microcontroller to deep sleep and power-cycle the MQ-2 through a MOSFET, but you'll need to wait 1-3 minutes for the sensor to stabilize on each wake.
Why does the MQ-2 trigger when I light a candle nearby?
Combustion releases hydrocarbons, smoke, and small amounts of unburned hydrogen — exactly what the MQ-2 is tuned to. It's an easy way to confirm the sensor is alive: light a match a meter away and watch AO climb.