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 () to decrease and raising the analog output voltage.
- Baseline Calibration (): Because ambient humidity and temperature affect resistance, the sensor must be calibrated in clean air to establish its baseline resistance ratio ().
-
The sensor resistance Rs is calculated as:
-
Calibration yields the baseline which is then used to estimate the gas concentration in ppm:
-
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 themq7_gas_read_estimated_ppmblock uses to compute its own PPM estimate from whatever voltage it reads back. In practice: settingcoLevelto, 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
coLevelanywhere 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> ppmlabel. - 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/HIGHcontinuously 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.

