Component guide · Beginner · 3 min read
MQ-7 Carbon Monoxide Sensor

Pinout, Wiring and Code
By Geekobot Learning Team · Updated 29 Oct 2026
On this page
The MQ-7 is a metal-oxide sensor for carbon monoxide (CO) from 20 to 2,000 ppm. The datasheet runs its heater in a cycle, 60 s at 5 V then 90 s at 1.4 V, and reads at the end of the low phase. Most modules keep the heater at 5 V, which shows trends but not accurate ppm. Use it for learning projects, not as a safety alarm.
Key specs at a glance
- Detects
- Carbon Monoxide
- Range
- About 20 to 2,000 ppm CO
- Heater
- 5 V, about 150 mA (about 0.75 W)
- Output
- Analog (AO) and digital threshold (DO) on modules
- Warm-up
- A few minutes before use; 24 to 48 hours of burn-in for stable readings
- Heater cycle
- Datasheet method: 5 V for 60 s, then 1.4 V for 90 s, read at the end of the low phase
Models in this guide
These are alternatives. Pick the one that fits your project; you only need one.
What the MQ-7 is
The MQ-7 detects carbon monoxide (CO), the poisonous gas from incomplete burning. It is meant to run with a two-step heater cycle: a hot phase at 5 V cleans the sensing layer, and CO is measured during a cooler phase at 1.4 V.
Most low-cost modules power the heater from a constant 5 V, so they show changes in CO but are less accurate than the datasheet method. MQ sensors are for hobby and learning projects. They are not certified gas alarms; for safety use an approved detector.
MQ-7 pinout
The pins on the MQ-7 and what each one does.
| Pin | Function |
|---|---|
| VCC | 5 V supply for the heater and the comparator |
| GND | Ground |
| AO | Analog output: rises as the gas level rises |
| DO | Digital output from the LM393 comparator; switches at the level set by the trim pot |
- VCC
- 5 V supply for the heater and the comparator
- GND
- Ground
- AO
- Analog output: rises as the gas level rises
- DO
- Digital output from the LM393 comparator; switches at the level set by the trim pot
Wiring the MQ-7
The heater draws about 150 mA, so power it from the 5 V rail, not a 3.3 V pin. The analog output can reach 5 V, so an ESP32 needs a divider (10 kΩ over 20 kΩ gives a third off) on AO.
| MQ-7 pin | Arduino Uno | ESP32 |
|---|---|---|
| VCC | 5V | 5V (VIN) |
| GND | GND | GND |
| AO | A0 | GPIO 34 through a 10k/20k divider |
| DO | D2 (optional) | GPIO 27 (optional, via divider) |
- VCC
- Arduino Uno:
- 5V
- ESP32:
- 5V (VIN)
- GND
- Arduino Uno:
- GND
- ESP32:
- GND
- AO
- Arduino Uno:
- A0
- ESP32:
- GPIO 34 through a 10k/20k divider
- DO
- Arduino Uno:
- D2 (optional)
- ESP32:
- GPIO 27 (optional, via divider)
Example code
Rs/R0 falls as the gas level rises. Convert it to ppm with the curve in the datasheet; treat the result as an estimate, not a certified reading.
const int AO = A0;
const float RL = 10.0; // load resistor on the module, kOhm (check yours)
const float CLEAN_AIR = 27.5; // Rs/R0 in clean air from the datasheet curve
float R0 = 0;
float readRs() {
long sum = 0;
for (int i = 0; i < 50; i++) { sum += analogRead(AO); delay(5); }
float v = (sum / 50.0) * 5.0 / 1023.0;
return RL * (5.0 - v) / v; // sensor resistance, kOhm
}
void setup() {
Serial.begin(115200);
Serial.println("Warming up 3 minutes in clean air...");
delay(180000);
R0 = readRs() / CLEAN_AIR; // calibrate in clean air
Serial.print("R0 = "); Serial.println(R0);
}
void loop() {
float ratio = readRs() / R0; // lower ratio = more gas
Serial.print("Rs/R0 = "); Serial.println(ratio, 2);
delay(1000);
}Setup and tuning
for better readings, switch the heater with a logic-level MOSFET and PWM it to about 1.4 V average for 90 s after each 60 s at 5 V; read just before the hot phase starts.
R0 in clean outdoor air.
CO mixes with air, so mount it at breathing height.
What you need
Shop this list4 of 6 found in our store · ₹671
MQ-7 carbon monoxide gas sensor module: the sensor this guide coversMQ-7 CO Carbon Monoxide Gas Sensor Module – Analog & Digital Output₹116Closest match, check the specs
Waveshare MQ-7 Carbon Monoxide Sensor Module – 20-2000ppm CO Detection: another version this guide coversWaveshare MQ-7 Carbon Monoxide Sensor Module – 20-2000ppm CO Detection₹479- Uno R3 development board: the controller used in the wiring tableFind this part
- IRLZ44N logic-level MOSFET: to cycle the heater as the datasheet asksFind this part
Buzzer module 3.3-5 V: for an audible alarmBuzzer Module 3.3–5V₹27
Dupont jumper wires: for the connectionsDupont Jumper Wires (40 pcs)₹49Closest match, check the specs
Alternatives and when to choose them
- MQ-9: CO plus combustible gases.
- Electrochemical gas sensors: accurate, selective CO measurement.
- MQ gas sensors: the family compared.
Try it: Voltage divider calculator
Change the values and the diagram and results update as you type.
Common mistakes to avoid
- Running the heater at a constant 5 V and expecting datasheet accuracy.
- Using it as a life-safety CO alarm.
- Calibrating R0 indoors near a stove.
- Testing with car exhaust in a closed space.
Frequently asked questions
What does the MQ-7 detect?
Carbon monoxide, with some response to hydrogen.
Why does the MQ-7 need a heater cycle?
The hot phase cleans the sensor and the low phase gives the CO reading; it is how the datasheet calibrates it.
Can I use it without cycling?
Yes for rough trends, but readings are less accurate.
Is it a CO alarm?
No. Use a certified CO alarm for safety.
Does it work on 3.3 V boards?
The heater needs 5 V; divide the analog output for 3.3 V ADCs.
Parts for this guide
Calculators
Projects that use it
Put this into practice: 18 step-by-step builds in our project library use parts from this guide.
Keep learning
Sources
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.


