MQ-7 Gas Sensor (Carbon Monoxide)

The MQ-7 is a SnO2 semiconductor-based gas sensor designed to detect carbon monoxide (CO) concentrations in ambient air.

Sensors9 blocksMicroPythonC++
MQ-7 Gas Sensor Module

At a glance

Pins and properties exactly as the circuit editor and simulator define this part. The text below explains how to use them.

Pinout

Pinout of the MQ-7 Gas Sensor Module, drawn as in the circuit editor. Select a label to see that pin in the table below.

Pins

Pins of this part
PinLabelType
VCCVCCPower in
GNDGNDGround
DODOSignal out
AOAOAnalog out

Properties

What you can change in the Property Inspector.

Properties of this part
PropertyRange or choicesDefault
CO Concentration10 to 500 ppm50 ppm
DO Threshold10 to 500 ppm100 ppm

The MQ-7 is a SnO2 semiconductor-based gas sensor designed to detect carbon monoxide (CO) concentrations in ambient air. The sensor utilizes a heating cycle to alternate between high and low temperatures, cleaning the sensor element before taking readings.


1. Hardware Specifications

  • Heater Power: Alternates between 5V (high heat phase, 60s) and 1.4V (low heat measurement phase, 90s).
  • Detection Concentration Range: 20 ppm to 2000 ppm of carbon monoxide (CO).
  • Pin Configuration:
    • VCC: Power input (5V required for internal heater coil).
    • GND: Common ground.
    • AO (Analog Output): Outputs a variable analog voltage proportional to the gas concentration.
    • DO (Digital Output): Digital alert pin. Pulls LOW when gas levels exceed the threshold set by the onboard potentiometer.


2. How it Works (Theory & Calibration)

  • Semiconductor Conductivity: In clean air, the conductivity of SnO2 is low. When CO gas is present, the sensor's conductivity increases, causing the internal resistance (RsR_s) to decrease and raising the analog output voltage.
  • Baseline Calibration (R0R_0): Because ambient humidity and temperature affect resistance, the sensor must be calibrated in clean air to establish its baseline resistance ratio (R0R_0).
    • The sensor resistance Rs is calculated as:

      Rs=Vin−VoutVout×RloadR_s = \frac{V_{in} - V_{out}}{V_{out}} \times R_{load}

    • Calibration yields the baseline R0R_0 which is then used to estimate the gas concentration in ppm:

      PPM=99.042×(RsR0)−1.518\text{PPM} = 99.042 \times \left( \frac{R_s}{R_0} \right)^{-1.518}


3. Component Properties

The MQ-7 now has a real simulated component (mq7) — drag it onto the Circuit Canvas from the Components palette. It exposes two adjustable properties in the Property Inspector:

  • CO Concentration (coLevel) — range 10–1000 ppm, default 50 ppm, step 5.
  • DO Threshold (threshold) — range 10–1000 ppm, default 100 ppm, step 5. This is the same value the real module's onboard blue trimmer potentiometer sets for its comparator.

All four pins from Section 1 are wired: AO outputs a real analog voltage that responds to coLevel, and DO is a real digital pin the simulator drives LOW whenever coLevel reaches threshold — matching the real comparator's active-low alert behavior.

[!NOTE] The simulator's internal analog curve (Rs = 10 kΩ × (ppm / 100)^-0.75, feeding a voltage divider against a fixed 1 kΩ load resistor) is a similarly-shaped approximation of a real MQ-7's resistance curve, but it is not the same curve as the datasheet-derived PPM formula in Section 2 (PPM = 99.042 × (Rs/R0)^-1.518), and it's also not the curve the mq7_gas_read_estimated_ppm block uses to compute its own PPM estimate from whatever voltage it reads back. In practice: setting coLevel to, say, 200 ppm on the canvas produces a plausible-looking AO voltage, but the PPM number your generated code computes back from that voltage won't exactly equal 200 — both curves move in the same direction, they just aren't numerically identical.


4. Simulator Behavior

With the component placed and the circuit running:

  • Drag the vertical gas-concentration slider on the right side of the component (visible only during simulation) to set coLevel anywhere from 10 ppm (clean air) to 1000 ppm — a semi-transparent orange "smoke cloud" above the sensor grows and pulses more intensely as the level rises, with a live <ppm> ppm label.
  • Click-drag the onboard blue trimmer potentiometer to set threshold (10–1000 ppm) — the same physical interaction a technician would use to calibrate the real module.
  • Two onboard LEDs reflect state live: a red PWR LED lights whenever the module is powered, and a green DAT LED lights whenever coLevel >= threshold (the moment DO goes LOW).
  • A live text readout above the component shows CO: <ppm>ppm AO: <V>V DO: LOW/HIGH continuously while powered — always-visible, not a hover-only tooltip.
  • If VCC drops below 4.5V while the module is powered, a LOW VCC fault is raised — the real heater coil needs a stable 5V supply to operate correctly.

5. Supported Blockly Blocks

Drawing the blocks…

MQ-7 Gas Sensor (Carbon Monoxide) — OMS Parts