MQ-7 Carbon Monoxide Sensor Tutorial: CO Detection Principles, Heater Cycling, and Arduino Usage
This tutorial is a comprehensive, practical guide to the MQ-7 Carbon Monoxide (CO) Gas Sensor Module (Leobot Product #522). It explains exactly what the MQ-7 is designed to detect, how it differs from other MQ-series sensors, the critical heater cycling requirement that makes the MQ-7 unique, and how to use it correctly with Arduino for carbon monoxide monitoring and alarm projects.
1) What the MQ-7 senses (and what it does not)
The MQ-7 is designed to detect carbon monoxide (CO), a colorless, odorless, and highly toxic gas produced by incomplete combustion.
MQ-7 is sensitive to
- Carbon monoxide (CO)
MQ-7 has limited response to
- Hydrogen (cross-sensitivity)
- Some hydrocarbons at high concentration
MQ-7 is NOT suitable for
- LPG, propane, or methane detection (use MQ-2 or MQ-4)
- Certified CO safety monitoring
- Accurate ppm measurement without calibration gases
2) How the MQ-7 carbon monoxide sensor works
The MQ-7 uses a heated tin dioxide (SnO2) sensing layer. Carbon monoxide reduces the surface resistance of this layer when present.
- Clean air ? higher sensor resistance
- CO present ? resistance decreases
- Resistance change ? voltage change at output
3) Why heater cycling is required
Unlike most MQ sensors that use constant heater power, the MQ-7 requires alternating heater voltages:
- High temperature phase: burns off contaminants and resets the sensor
- Low temperature phase: optimized for CO sensitivity
Typical cycle:
- 5V heater for ~60 seconds (cleaning phase)
- 1.4V heater for ~90 seconds (measurement phase)
4) CO selectivity and cross-sensitivity
The MQ-7 is optimized for CO but is not perfectly selective.
- Strong response to carbon monoxide
- Moderate response to hydrogen
- Lower response to alcohol and methane
This makes it suitable for CO monitoring but not for complex gas discrimination.
5) Module overview and onboard electronics
The MQ-7 module typically includes:
- MQ-7 sensing element with heater
- Load resistor for voltage divider output
- LM393 comparator for digital output
- Threshold potentiometer
- Status LED
Most modules expose both analog and digital outputs, but the digital output still depends on proper heater cycling.
6) Pinout and electrical characteristics
| Pin | Label | Description |
|---|---|---|
| 1 | AO | Analog output (CO level proxy) |
| 2 | GND | Ground |
| 3 | VCC | Module logic supply (5V) |
| 4 | DO | Digital output (threshold-based) |
- Heater current can exceed 150 mA
- Designed for 5V operation
7) Power supply and heater control
The heater must be driven with two different voltages. This is usually done using:
- A transistor or MOSFET controlled by Arduino
- A resistor divider or DC-DC converter for 1.4V phase
8) Analog vs digital outputs
Analog Output (AO)
- Must be read during the low-temperature phase
- Provides relative CO concentration information
- Required for meaningful use
Digital Output (DO)
- Comparator-based alarm signal
- Threshold adjusted via potentiometer
- Only valid if heater cycling is correct
9) Wiring to Arduino
MQ-7 VCC ? Arduino 5V
MQ-7 GND ? Arduino GND
MQ-7 AO ? Arduino A0
MQ-7 DO ? Arduino D2
Heater control ? Arduino digital pin (via transistor)
10) Arduino Example 1: Heater cycling control
/*
MQ-7 Heater Cycling Example
Simplified demonstration only
*/
const int HEATER_PIN = 8;
void setup() {
pinMode(HEATER_PIN, OUTPUT);
}
void loop() {
// High-temp phase (5V)
digitalWrite(HEATER_PIN, HIGH);
delay(60000); // 60 seconds
// Low-temp phase (approx 1.4V via resistor network)
digitalWrite(HEATER_PIN, LOW);
delay(90000); // 90 seconds
}
11) Arduino Example 2: CO level reading
/*
MQ-7 CO Sensor - Analog Read
Read during low-temperature phase
*/
const int MQ7_AO = A0;
void setup() {
Serial.begin(9600);
}
void loop() {
int value = analogRead(MQ7_AO);
Serial.print("CO level: ");
Serial.println(value);
delay(500);
}
12) Arduino Example 3: CO alarm logic
/*
MQ-7 CO Sensor - Alarm Logic
*/
const int MQ7_AO = A0;
const int BUZZER = 9;
const int CO_THRESHOLD = 300; // adjust after calibration
void setup() {
pinMode(BUZZER, OUTPUT);
Serial.begin(9600);
}
void loop() {
int value = analogRead(MQ7_AO);
if (value > CO_THRESHOLD) {
digitalWrite(BUZZER, HIGH);
Serial.println("WARNING: CO detected!");
} else {
digitalWrite(BUZZER, LOW);
}
delay(500);
}
13) Calibration and baseline setup
Calibration is relative and requires a clean-air baseline.
- Allow full heater cycle stabilization
- Measure baseline in clean air during low-temp phase
- Set thresholds above baseline
- Adjust using test gas if available
14) Environmental effects and limitations
- Humidity affects sensitivity
- Temperature drift alters readings
- Cross-sensitivity to hydrogen
- Sensor aging over time
15) Typical applications
- Carbon monoxide monitoring experiments
- Educational safety demonstrations
- Engine exhaust detection
- Indoor air quality experiments
16) Troubleshooting
Unstable readings
- Incorrect heater cycling
- Reading during wrong phase
- Power supply instability
No response to CO
- Heater not driven correctly
- Incorrect wiring
- Sensor damaged or aged
17) Quick checklist
MQ-7 Carbon Monoxide Sensor (#522) Checklist
-------------------------------------------
? Use stable 5V supply with sufficient current
? Implement heater voltage cycling
? Read sensor only during low-temp phase
? Treat readings as relative values
? Expect cross-sensitivity to hydrogen
? Do NOT use as certified safety device
? Recalibrate periodically