The Ultimate Arduino Gas Detector Quick Reference & FAQ
Building a DIY Arduino gas detector using the ubiquitous MQ-series metal-oxide-semiconductor (MOS) sensors is a rite of passage for embedded systems makers. Whether you are monitoring indoor air quality, detecting combustible gas leaks, or logging environmental data, these sensors offer an affordable entry point. However, translating raw analog readings into accurate Parts Per Million (PPM) requires understanding sensor chemistry, load resistor math, and microcontroller ADC quirks.
This quick reference guide and FAQ addresses the most common hardware pitfalls, calibration formulas, and edge cases encountered when deploying MQ sensors with Arduino Uno, Nano, and ESP32 boards in 2026.
MQ Sensor Selection Matrix
Choosing the correct sensor is critical. Each MQ sensor utilizes a tin dioxide (SnO2) layer that changes conductivity in the presence of specific target gases. Below is a quick-reference matrix for the most common models available on the maker market, including typical 2026 pricing and clean-air baseline ratios.
| Sensor Model | Primary Target Gas | Clean Air Ratio (Rs/R0) | Heater Voltage | Avg. Price (2026) |
|---|---|---|---|---|
| MQ-2 | LPG, Propane, Smoke, H2 | 9.8 | 5.0V ± 0.2V | $1.50 - $2.50 |
| MQ-3 | Alcohol, Ethanol Vapor | 60.0 | 5.0V ± 0.2V | $1.80 - $3.00 |
| MQ-4 | Methane, Natural Gas (CH4) | 4.4 | 5.0V ± 0.2V | $2.00 - $3.50 |
| MQ-7 | Carbon Monoxide (CO) | 27.0 | Pulsed (5V/1.5V) | $2.50 - $4.00 |
| MQ-9 | CO and Combustible Gases | 9.6 | Pulsed (5V/0.9V) | $3.00 - $4.50 |
| MQ-135 | NH3, NOx, Benzene, Smoke | 3.6 | 5.0V ± 0.2V | $1.50 - $2.50 |
Pro-Tip: The "Clean Air Ratio" is the baseline resistance of the sensor (Rs) divided by the reference resistance (R0) in standard atmospheric conditions. You must know this exact ratio to calibrate your code.
Hardware & Wiring FAQs
Why is my MQ sensor too hot to touch?
This is entirely normal and by design. The sensor contains an internal micro-heater coil that raises the SnO2 sensing layer to roughly 300°C–400°C. This high temperature is required to trigger the chemical oxidation-reduction reaction that changes the sensor's conductivity. A standard MQ-2 draws about 150mA at 5V (roughly 750mW). If it is cold, it is broken or underpowered.
Can I power an MQ sensor directly from an ESP32 or ESP8266 3.3V pin?
Absolutely not. This is the most common mistake makers make. The 3.3V voltage regulators on most ESP32/ESP8266 dev boards are rated for 500mA to 800mA max, and the board's main logic already consumes a significant portion of that. An MQ sensor pulling 150mA+ continuously will cause a voltage drop, leading to microcontroller brownouts, Wi-Fi disconnects, and erratic ADC readings. Always power the MQ sensor's VCC pin from an external 5V buck converter or the 5V pin of a USB-powered Arduino Uno.
What is the Load Resistor (RL) and why does it matter?
MQ sensors do not output a voltage directly; they act as variable resistors. The breakout board includes a fixed load resistor (RL) to form a voltage divider. Most cheap breakout boards use a 1KΩ or 10KΩ surface-mount resistor (check the silkscreen on your specific board). You must know your exact RL value to calculate the sensor's resistance (Rs) using the formula:
Rs = ((Vc / Vrl) - 1) * RL
Where Vc is the circuit voltage (usually 5V) and Vrl is the analog voltage read by the Arduino.
Calibration & Math FAQs
How do I find the R0 value for my specific sensor?
R0 is the sensor's baseline resistance in clean air. To find it, you must perform a "burn-in" and a baseline calibration:
- Burn-In: Power the sensor continuously in clean outdoor air for 24 to 48 hours. New sensors exhibit massive resistance drift during their first day of operation as manufacturing residues burn off.
- Read Vrl: After burn-in, use a multimeter to measure the exact voltage at the analog output pin, or use your Arduino's serial monitor to read the raw ADC value.
- Calculate Rs: Use the voltage divider formula mentioned above.
- Calculate R0: Divide Rs by the Clean Air Ratio from the table above. For an MQ-2,
R0 = Rs / 9.8.
How do I convert Rs/R0 into PPM?
The relationship between the resistance ratio (Rs/R0) and gas concentration (PPM) is logarithmic, not linear. If you plot the datasheet's sensitivity curves on a log-log graph, you get a straight line defined by the equation:
log10(PPM) = m * log10(Rs/R0) + c
Therefore, the code implementation requires extracting the slope (m) and y-intercept (c) from the specific sensor's datasheet graph. For example, for an MQ-2 detecting LPG, the approximate constants are m = -0.45 and c = 1.35. Your Arduino code should compute:
float ppm = pow(10, (m * log10(Rs/R0)) + c);
Edge Cases & Troubleshooting
The MQ-7 Carbon Monoxide Pulsing Requirement
If you are building an Arduino gas detector specifically for Carbon Monoxide using the MQ-7, be aware that standard 5V continuous power will yield highly inaccurate results. The Hanwei datasheet strictly requires a pulsed heater voltage: 1.5V for 90 seconds (to clean the sensor of residual gases) followed by 5.0V for 60 seconds (the actual measurement window).
Most commercial breakout boards ignore this and wire the heater directly to 5V. To fix this, advanced makers build a custom breakout using an N-channel MOSFET (like the IRLZ44N or AO3400) and PWM to dynamically control the heater voltage, ensuring compliance with EPA Carbon Monoxide monitoring guidelines for accurate low-PPM detection.
ESP32 ADC Non-Linearity and Saturation
If your Arduino gas detector uses an ESP32, you will encounter ADC non-linearity. The ESP32's 12-bit ADC is notoriously inaccurate above 2.5V and completely saturates near 3.1V, meaning you will lose all resolution when the MQ sensor outputs higher voltages in clean air.
The Fix: Implement a hardware voltage divider on the analog output pin. Using two 10KΩ resistors will halve the 0-5V output down to a 0-2.5V range, keeping it within the ESP32's linear ADC zone. Simply multiply the final ADC reading by 2 in your software to compensate.
Safety and Compliance Warning
While building an Arduino gas detector is an exceptional educational project and useful for trend-logging, MOS sensors are not certified for life-safety applications. They are highly susceptible to cross-sensitivity (e.g., an MQ-4 methane sensor will also trigger heavily in the presence of alcohol vapor or humidity spikes). Furthermore, the SnO2 layer degrades over 2 to 5 years, leading to silent failures.
For actual home safety, always rely on UL-listed, certified electrochemical or catalytic bead detectors. For comprehensive occupational exposure limits and chemical hazard data regarding the gases these sensors detect, refer to the NIOSH Pocket Guide to Chemical Hazards. Never use a DIY microcontroller setup as a primary replacement for certified life-safety alarms in residential or industrial environments.






