The MQ-2 combustible gas and smoke sensor outputs an analog voltage (0V to VCC) across an onboard load resistor, which inversely correlates to the concentration of smoke and off-gases in the air. While many hobbyists treat this as a simple digital alarm, extracting actual parts-per-million (PPM) data requires a specific voltage-divider calculation and a logarithmic scaling curve. This guide provides the exact circuit wiring, the raw-to-unit math, and the calibration sequence required to turn a basic MQ-2 datasheet into a functional embedded smoke detector sensor circuit.
The Sensing Principle: How the MQ-2 Detects Smoke
The MQ-2 relies on a tin dioxide (SnO2) semiconductor layer heated by an internal nichrome coil. In clean air, oxygen molecules adsorb onto the SnO2 surface, trapping electrons and creating a potential barrier that keeps the material's electrical conductivity low. When a fire begins, it releases smoke particulates and combustible off-gases (like carbon monoxide and unburned hydrocarbons) that interact with the heated sensor surface, reacting with the adsorbed oxygen.
This chemical reaction releases the trapped electrons back into the conduction band, drastically lowering the sensor's internal resistance. The sensor is wired in a voltage divider with a fixed surface-mount load resistor ($R_L$) on the module. As the SnO2 resistance drops in the presence of smoke, the voltage across the load resistor increases, yielding a higher analog output voltage that your microcontroller's ADC can read.
Wiring the Smoke Detector Sensor Circuit
The standard MQ-2 breakout board includes an LM393 comparator for digital output and a potentiometer for threshold tuning. For precise PPM tracking, we ignore the digital pin and read only the raw analog signal. Below is the pinout and required supply range.
| Module Pin | Supply Range / Signal | Microcontroller Connection |
|---|---|---|
| VCC | 5.0V ± 0.1V (Heater requires 5V) | 5V Pin (Do not use 3.3V) |
| GND | 0V (Common Ground) | GND |
| A0 | Analog Out (0V to ~5V) | ADC Pin (via voltage divider*) |
| D0 | Digital TTL (0V or 5V) | Leave Disconnected |
Output Signal Math: Raw ADC to Smoke PPM
Converting the raw ADC reading into a physical unit (PPM) requires a three-step mathematical sequence. We will assume a 12-bit ADC (like the ESP32 or Arduino Due) with a 3.3V reference, and a standard MQ-2 module with a 1kΩ onboard load resistor ($R_L$).
- Convert Raw ADC to Voltage ($V_{out}$):
Calculate the voltage across the load resistor. If using the ESP32 voltage divider mentioned above, multiply the result by 2.
V_out = (ADC_raw / 4095.0) * 3.3 * Voltage_Divider_Multiplier - Calculate Sensor Resistance ($R_s$):
Using the voltage divider rule, solve for the SnO2 sensor resistance. $V_c$ is the circuit voltage (5.0V).
R_s = ((V_c / V_out) - 1.0) * R_L
Example: If V_out is 1.5V, R_s = ((5.0 / 1.5) - 1.0) * 1000 = 2333Ω. - Apply the Log-Log Sensitivity Curve:
The Hanwei MQ-2 datasheet plots PPM on a logarithmic scale against the $R_s/R_0$ ratio. For smoke, the linear regression of the log-log curve yields a slope ($m$) of approximately -0.42 and a y-intercept ($b$) of 1.1. The final formula is:
PPM = 10 ^ ((log10(R_s / R_0) - b) / m)
This math strictly applies to the analog output. Conflating this with the digital D0 pin will ruin your data logging, as the D0 pin merely flips high/low based on a physical potentiometer threshold and provides zero concentration data.
Calibration, Scaling, and Interference Sources
The math above relies on $R_0$, the baseline resistance of the sensor in clean air. You cannot use a hardcoded $R_0$ value; it must be calibrated on your specific bench because manufacturing tolerances and local ambient temperatures shift the baseline.
The Clean-Air Calibration Routine
In clean air, the datasheet specifies that the $R_s/R_0$ ratio is approximately 9.8. To find your specific $R_0$:
- Power the sensor in a well-ventilated room free of VOCs, smoke, or alcohol.
- Allow the sensor to burn-in for 5 minutes. The internal heater must reach thermal equilibrium (~200°C).
- Read $V_{out}$ and calculate $R_s$ using Step 2 above.
- Calculate $R_0 = R_s / 9.8$. Store this $R_0$ value in your microcontroller's EEPROM or code constants.
Common Interference Sources
The SnO2 layer is notoriously cross-sensitive. When debugging false positives in your smoke detector sensor circuit, check for these environmental factors:
- Humidity: High relative humidity (>70%) causes water vapor to adsorb on the SnO2, artificially lowering resistance and triggering false smoke readings. Add a software compensation curve if using a BME280 alongside the MQ-2.
- Ethanol and Alcohols: Isopropyl alcohol, hand sanitizer, or even wine vapors will cause massive spikes in the analog output, often maxing out the ADC.
- Silicone Off-Gassing: If you pot the circuit in cheap silicone sealant, the curing VOCs will poison the sensor surface, permanently altering the baseline $R_0$.
Decision Tree: Which Sensor Should You Actually Buy?
Not every project requires a semiconductor gas sensor. Use this decision matrix to select the correct hardware for your specific embedded application, avoiding the common mistake of buying a gas sensor for a particulate problem.
| Application Requirement | Sensor Technology | Action / Part Number |
|---|---|---|
| Life-Safety / Code Compliance (Bedrooms, hallways, legal rentals) | Certified Photoelectric / Ionization Chamber | Stop. Buy a commercial UL-listed Kidde or First Alert detector. |
| Ash, Soot, and Fire Particulates (Detecting actual burning physical matter) | Optical Photoelectric Scattering | Use the HW-720 Photoelectric Optical Smoke Module. |
| Smoldering Gases & Early Off-Gassing (LPG leaks, CO, pre-fire VOCs) | SnO2 Semiconductor (Analog PPM) | Use the MQ-2 with the math provided above. |
| Default Maker Pick: General IoT alarm prototyping, air quality logging, and basic combustion detection. | Semiconductor + Comparator | Buy the MQ-2 Module (with onboard LM393 and 1kΩ load resistor). |
For general embedded prototyping where you need to log combustion off-gases and build custom alarm thresholds via ESP32 ADC peripherals, the MQ-2 Module with an onboard LM393 and 1kΩ load resistor is the definitive concrete pick. It provides the raw analog voltage necessary for the $R_s/R_0$ PPM math, while the included comparator gives you a fallback hardware interrupt pin if your microcontroller crashes.






