MQ-2 gas sensor module
MQ-2 module pinout, 5 V heater current, burn-in and warm-up time, keeping AO within a 3.3 V ADC, and why it is not a certified alarm.
Community draft — report a mistake
3.3 V or 5 V? The heater needs 5 V. AO can reach about 5 V, so on ESP32 and Pico feed AO through a 10 kΩ / 20 kΩ divider (or similar) to stay under 3.3 V. DO is driven by the comparator from VCC — divide it too on 3.3 V boards.
The MQ-2 is a heated tin-dioxide (SnO₂) sensor whose resistance falls when it meets LPG, propane, butane, methane, hydrogen and smoke. It’s used in DIY smoke and gas-leak alarms.
It reacts to many gases at once, so it tells you something is in the air, not exactly what.
It needs heat. The element runs at about 5 V and 150 mA — it gets warm, and that’s normal. Give a new sensor a 24–48 hour burn-in, and a few minutes of warm-up after every power-on. The analog value isn’t calibrated in ppm out of the box; treat it as “higher = more gas” relative to clean-air readings.
Not a certified safety device. A DIY MQ alarm is a helpful extra warning, not a replacement for a certified gas or smoke detector. Keep a certified detector, and for LPG leaks: no switches, no flames, open windows, close the cylinder valve.
Prices are indicative (Oct 2026) and vary by seller.
Pinout
| Pin | What it does |
|---|---|
VCC | 5 V supply — the heater draws about 150 mA |
GND | Ground |
DO | Comparator output: changes state when gas concentration crosses the pot setting (about 5 V HIGH) |
AO | Analog output rising with gas concentration (0–~5 V) |
Use it with
- MQ-2 gas sensor module with Arduino Nano Arduino C++
- MQ-2 gas sensor module with Arduino Uno R3 Arduino C++
- MQ-2 gas sensor module with ESP32-C3 SuperMini Arduino C++
- MQ-2 gas sensor module with ESP32 DevKit V1 Arduino C++
- MQ-2 gas sensor module with NodeMCU ESP8266 Arduino C++
- MQ-2 gas sensor module with Raspberry Pi Pico W MicroPython
Common errors
Readings drift for the first hours
New sensors need a burn-in of 24–48 hours powered on; every time after, allow a few minutes of warm-up before trusting the value.
ESP32 resets or the USB port cuts out
The heater pulls about 150 mA. Power the module from a proper 5 V supply, not a weak USB port or the 3.3 V pin.
Value changes with weather
Humidity and temperature shift the reading. Compare against a baseline recorded in clean air at similar conditions rather than a fixed number.
ESP32 ADC reads 4095 constantly
AO is above 3.3 V. Add the voltage divider and use an ADC1 pin.