Gas & Air Quality
Interfacing MQ 7 Gas & Air Quality with Arduino Uno
What is the MQ 7?
MQ 7 practical reference
A gas sensor calibrated specifically for carbon monoxide detection, used in DIY CO alarm and indoor air-safety projects.
Key specifications
- Sensing element: SnO2 (tin dioxide) semiconductor, sensitivity decreases as CO concentration decreases in clean air
- Operating voltage: 5 V DC (heater circuit and sensing circuit both run on 5V)
- Detection range: 20-2000 ppm carbon monoxide (CO)
- Heating cycle: 5 V for 60s (high-temp burn-off), then 1.4V for 90s (low-temp sensing) — 150s total cycle for spec-accurate CO readings
- Current draw: ~150 mA during the 5V heating phase — noticeably more than typical digital sensors, budget accordingly
- Preheat time: Usable within minutes, but full stabilization for accurate baseline readings takes up to 48 hours of burn-in
- Output: Analog voltage (AOUT) proportional to gas concentration, plus a threshold digital output (DOUT) via onboard comparator
- Interface: Analog (AOUT) — requires ADC and Rs/Ro curve conversion to get ppm; DOUT is a simple threshold trigger
Pinout and connection notes
The heating cycle is not optional for spec accuracy — many breakout boards simply tie VCC straight to a constant 5V, which the sensor will tolerate and still respond to CO, but the datasheet's accuracy figures assume the 60s-high/90s-low duty cycle. If CO-selectivity actually matters for your project (vs. just "some gas is present"), drive the heater pin with a MOSFET or relay on a timer/PWM to reproduce that cycle rather than running it at a constant voltage.
AOUT is raw voltage, not ppm — converting to a ppm figure requires computing the Rs/Ro resistance ratio and mapping it against the sensor's datasheet curve, plus a clean-air calibration step to establish your board's Ro baseline. Treat raw analogRead() values as relative/qualitative unless you've done this calibration.
DOUT needs calibration too — the trigger threshold is set by the onboard potentiometer and is not accurate out of the box. Adjust it while exposing the sensor to a known-safe CO level (i.e., clean air) before trusting DOUT as an alarm trigger.
Power budget — the ~150mA heater draw is easy to overlook if you're used to sub-10mA digital sensors. On a 3.3V-logic board reading AOUT through a voltage divider, make sure your 5V supply rail (not just logic) can actually source this current, especially if several MQ-series sensors run simultaneously.
Sensor lifetime and drift — SnO2 elements degrade over 1-3 years of use and drift with humidity and temperature; periodic recalibration against known-clean air is necessary for any long-term deployment, not just a one-time setup step.
- VCC: Power, 5V DC — also powers the internal heating element
- GND: Ground
- AOUT: Analog voltage output, proportional to gas concentration — read with an ADC, not a direct ppm value
- DOUT: Digital threshold output — trips based on the onboard comparator, threshold set by the potentiometer on the module
Integration checklist
- Confirm the exact part number and breakout-board revision.
- Verify supply voltage, current demand, logic levels, and signal direction against the datasheet.
- Check controller pin assignments and bus address or interface mode against the example code.
- Power up with external loads disconnected, then test signals before full integration.
- If readings or communication fail, check power and ground first, then pin mapping, interface settings, and library initialization.
Troubleshooting and reproducibility
Record the board used, wiring, library/version, supply arrangement, and measured behavior. Use the selected board-specific wiring example as the source of truth. Never assume visually similar modules share identical voltage tolerance or pin order.
Setting Up MQ 7 with Arduino Uno
Wiring
| Component pin | Arduino Uno pin | Note |
|---|---|---|
| VCC | 5V | Most breakout modules include the heater-drive circuitry onboard — a plain 5V here is fine for those |
| GND | GND | |
| AOUT | A0 | Analog voltage output — rises with detected CO concentration |
| DOUT | D2 (optional) | Digital threshold trigger; trip point set by the onboard potentiometer |
Swipe sideways to see every column →
- The MQ-7 datasheet specifies cycling the heater between 5V for 60s and 1.4V for 90s to get spec-accurate CO ppm. This sketch (and most breakout boards) just runs the heater at a constant 5V instead — it still detects CO reliably for alarm/threshold use, but won't match the datasheet's ppm curve exactly.
- For datasheet-accurate readings, drive the heater through a transistor switched by a second digital pin and follow the 60s/90s cycle in code, rather than tying VCC straight to 5V.
- Give it a few minutes of warm-up, and expect the baseline to keep settling for the first day or two of total run time, same as the rest of the MQ family. Carbon monoxide detection is safety-relevant — don't rely on this as your only CO alarm.
Related Components
Related Guides & Projects
Arduino Uno R4 Minima Pinout: Every GPIO, ADC, DAC, and Op-Amp Pin Explained
A complete Arduino Uno R4 Minima pinout reference — digital I/O, ADC, DAC, op-amp, CAN, dual UART, and exactly what it leaves out compared to the WiFi variant.
Mastering PWM on Arduino: Dimming LEDs and Controlling Motors
Understand what PWM actually is on Arduino, dim an LED smoothly, and safely control a DC motor's speed with a driver chip -- plus the mistakes (like wiring a motor straight to a pin) that damage boards.
4-Digit 7-Segment Counter with TM1637 & Arduino
Drive a TM1637-based 4-digit 7-segment display with Arduino Uno to show a real-time up/down counter, elapsed timer, and scrolling text. Covers library setup, brightness control, and custom segment mapping.
Arduino Uno R4 Minima vs WiFi: Which One Should You Choose?
Same processor, same memory, different price. Here's what the WiFi variant's extra hardware actually gets you, and when the Minima is the smarter buy.