Same-day dispatch before 2 PM · Free delivery over ₹999 · GST invoices Get the appPrices incl. GST
Geekobot
Snap & SendNEWGeeko AIWhere's myOrder
Log in
Products
  • Projects
    • Component guidesHow parts work, with code you can run
    • Learning pathsFrom your first LED to your first robot
    • Workshops & eventsOnline sessions for makers and classes
    • ElectrolarkFree guided builds, simulator and certificates
    • Students & teachersStudent discount and classroom help
    • CommunityShare builds and ask other makers
    • CalculatorsOhm's law, LED resistor, 555 and 100+ more
    • Circuit builderWire parts and run the circuit, powered by Electrolark
    • Geeko AIAsk what to buy or how to wire it
    • Snap & SendPhotograph a part or list, we find it
    • Part finderAnswer a few questions, get the right part
    • Compatibility checkWill these two parts work together?
    • Compare partsSpecs side by side
    • Business & bulk ordersGST invoices, credit and volume prices
    • Request a quotationSend your list, get a quote
    • Classroom kitsPer-student kits and lab bundles
    • Gift cardsFor students, teams and events
  • Atal Tinkering Lab
BOM to cart
Geekobot

Components, kits and know-how for makers, students, engineers, labs and businesses across India.

Ask Geeko AIOrders, parts and projects, any timeEmail supportReply within 1 working dayGet the Geekobot appAdd it to your home screen, free

Follow us

Shop

  • Boards & SBCs
  • Sensors & Modules
  • IoT & Wireless
  • Drone & FPV
  • 3D Printing
  • Filaments & Resins
  • Motors & Drivers
  • Power & Batteries
  • Semiconductors
  • Passive
  • Displays & LEDs
  • Switches & Relays
  • Wires & Cables
  • Prototyping
  • Tools & Test
  • Robotics
  • STEM Kits
  • Atal Tinkering Lab
  • Mechanical Parts
  • Audio

Orders

  • Track your order
  • Help & support
  • Shipping and delivery
  • Refunds and cancellation
  • Contact us

Learn

  • Projects
  • Geeko AI project assistant
  • Learning paths
  • Guides
  • Calculators
  • Electrolark: free guided builds

Part tools

  • Part finder
  • Compare parts
  • Will it work with my board?

Institutions

  • Classroom kits
  • Atal Tinkering Lab
  • Students & teachers
  • Workshops & Events

Business

  • Business & education
  • Request a quotation
  • BOM bulk upload
  • Quick order by SKU

Company

  • About Geekobot
  • Community
  • Gift cards
  • Terms & conditions
  • Privacy policy
  • Product directory
  • Sitemap

© 2026 Geekobot, a trade name of OLatus Systems Private Limited. All rights reserved.

20, 1st Floor, Neeladri Complex, 10th Cross, Sampige Rd, 2nd Main, Malleshwaram, Bengaluru, Karnataka 560003 · GSTIN 29AACCO0462F1ZM

+91 91810 15607 · connect@geekobot.in · Monday to Saturday, 10 AM to 2 PM IST

UPI · CARDS · NETBANKING · GST INVOICES

ShopProjectsGeeko AIGuides
Compare 0 parts →
Log in

Shop by category

Shop all components
  • Boards & SBCs1,910 products
    • Alternative Single Board Computers
    • Arduino Ecosystem
    • FPGA & Logic Boards
    • Microcontroller & Wireless Boards
    View all
  • Sensors & Modules4,701 products
    • Biomedical & Heart Rate
    • Current, Voltage & Power
    • Force, Weight & Pressure
    • Gas, Weather & Environmental
    View all
  • IoT & Wireless2,314 products
    • RF Modules
    • RFID & NFC
    • Antennas & RF Accessories
    • Cameras & Smart Vision
    View all
  • Drone & FPV3,558 products
    • Flight Control & Navigation
    • FPV Video & Optics
    • Frames & Structural Parts
    • Motors & Propulsion
    View all
  • 3D Printing2,204 products
    • 3D Printers
    • 3D Scanners & Digitizers
    • Laser Engravers & Cutters
    • Material Management & Upgrades
    View all
  • Filaments & Resins1,472 products
    • Filaments
    • Photopolymer Resins
    View all
  • Motors & Drivers463 products
    • BLDC Motor Drivers
    • DC & Geared Motors
    • DC Motor Drivers
    • Linear Actuators & Solenoids
    View all
  • Power & Batteries557 products
    • Battery Holders & Connectors
    • Breadboard Power
    • Chargers & BMS
    • DC-DC Converters
    View all
  • Semiconductors295 products
    • Diodes & Rectifiers
    • Interface & RF Encoder ICs
    • Logic ICs (74xx)
    • Logic ICs (CD4000)
    View all
  • Passive67 products
    • Capacitors
    • Circuit Protection
    • Crystals & Oscillators
    • Inductors
    View all
  • Displays & LEDs572 products
    • 7-Segment & Dot Matrix
    • Addressable LEDs
    • Character LCDs
    • Graphic LCDs
    View all
  • Switches & Relays184 products
    • Keypads & Touch
    • Push Buttons & Tactile
    • Relay Modules
    • Relays
    View all
  • Wires & Cables233 products
    • Board-to-Wire Connectors
    • Crimp & Splice
    • Headers & Dupont
    • Heat Shrink & Sleeving
    View all
  • Prototyping101 products
    • Breadboards
    • Interface Modules
    • PCBs & Perfboards
    View all
  • Tools & Test717 products
    • Bench Power Supplies
    • Hand Tools
    • Measuring Tools
    • Meters & Testers
    View all
  • Robotics180 products
    • Humanoid & Legged Robots
    • Robot Chassis & Platforms
    • Robotic Arms & Grippers
    • Wheels & Casters
    View all
  • STEM Kits268 products
    • Arduino Learning Kits
    • Coding & IoT Kits
    • Early Coding (Ages 3-8)
    • Invention Kits
    View all
  • Atal Tinkering Lab196 products
    • Package 1: Electronics, Robotics, IoT and Sensors
    • Package 2: Rapid Prototyping Tools
    • Package 3: Mechanical, Electrical and Measurement Tools
    • Package 4: Power Supply, Accessories and Safety Equipment
    View all
  • Mechanical Parts212 products
    • Bearings
    • Brackets & Mounts
    • Couplers
    • Fasteners & Standoffs
    View all
  • Audio109 products
    • Amplifier Modules
    • Buzzers & Sirens
    • Speakers
    View all
  1. Home
  2. ›Guides
  3. ›Sensors
  4. ›MQ Gas Sensors

Component guide · Intermediate · 3 min read

MQ Gas Sensors

MQ-2, MQ-135, MQ-7 and How to Use Them

By Geekobot Learning Team · Updated 24 Oct 2026

I'm using
Wiring, code and the Run it panels follow your board.
On this page
Short answerWhich MQ sensor do you need?How an MQ sensor worksWiring to Arduino and ESP32Getting a ppm estimateBetter sensors for real measurementsTry itCommon mistakesFAQsParts and next steps
Short answer

MQ sensors are cheap metal-oxide gas sensors: a heated tin-dioxide surface changes resistance when gas is present. The MQ-2 senses smoke, LPG and methane, the MQ-135 senses air quality (ammonia, benzene, CO2-like pollution) and the MQ-7 carbon monoxide. They need 5 V at about 150 mA for the heater, a 24 to 48 hour burn-in, and calibration before any ppm value means anything.

Key specs at a glance

Heater
5 V, about 150 mA (0.75 W); the module gets warm
Output
Analog (gas level) and digital (threshold via trimmer)
Warm-up
20 seconds to a few minutes; burn-in 24 to 48 hours for stable readings
Sensitivity
Changes with temperature and humidity
Response
Seconds; recovery can take minutes
Not for
Safety-critical alarms; use a certified detector
01

Which MQ sensor do you need?

SensorDetectsTypical use
MQ-2Smoke, LPG, propane, methane, hydrogenKitchen smoke or gas-leak demo
MQ-3Alcohol vapourBreathalyser projects
MQ-4Methane, natural gas (CNG)Gas leak demo
MQ-5LPG, natural gasGas leak demo
MQ-6LPG, butaneLPG cylinder leak demo
MQ-7Carbon monoxideCO monitoring experiments
MQ-8HydrogenLab projects
MQ-9CO and flammable gasCombined demo
MQ-135Ammonia, benzene, smoke, air qualityIndoor air-quality indicator
MQ-2
Detects:
Smoke, LPG, propane, methane, hydrogen
Typical use:
Kitchen smoke or gas-leak demo
MQ-3
Detects:
Alcohol vapour
Typical use:
Breathalyser projects
MQ-4
Detects:
Methane, natural gas (CNG)
Typical use:
Gas leak demo
MQ-5
Detects:
LPG, natural gas
Typical use:
Gas leak demo
MQ-6
Detects:
LPG, butane
Typical use:
LPG cylinder leak demo
MQ-7
Detects:
Carbon monoxide
Typical use:
CO monitoring experiments
MQ-8
Detects:
Hydrogen
Typical use:
Lab projects
MQ-9
Detects:
CO and flammable gas
Typical use:
Combined demo
MQ-135
Detects:
Ammonia, benzene, smoke, air quality
Typical use:
Indoor air-quality indicator
02

How an MQ sensor works

Inside the mesh cap is a tiny ceramic tube with a tin-dioxide coating and a heater coil. When heated to a few hundred degrees, the coating's resistance drops in the presence of reducing gases. The module turns that resistance into a voltage with a load resistor, and an LM393 comparator gives a digital alarm output when the voltage passes the trimmer's threshold.

03

Wiring to Arduino and ESP32

Four pins: VCC (5 V), GND, A0 (analog), D0 (digital). The heater must have 5 V. On an ESP32 or Pico the analog output can reach 5 V, so add a voltage divider (for example 10 kΩ and 20 kΩ) before the ADC pin.

Read an MQ-2 and raise an alarm · Arduino C++Verify & upload in Electrolark
const int A_PIN = A0;
const int D_PIN = 7;
const int LIMIT = 400;      // raw value, set from your own tests

void setup() {
  Serial.begin(9600);
  pinMode(D_PIN, INPUT);
  delay(20000);             // let the heater warm up
}

void loop() {
  int v = analogRead(A_PIN);
  Serial.print("Gas level: "); Serial.println(v);
  if (v > LIMIT || digitalRead(D_PIN) == LOW) Serial.println("ALARM");
  delay(1000);
}
04

Getting a ppm estimate

The datasheet graphs relate the ratio Rs/Ro to gas concentration on a log-log scale, where Ro is the sensor resistance in clean air. To estimate ppm:

  1. 1
    Burn the sensor in for 24 to 48 hours.
  2. 2
    In clean air, measure the analog value, convert to Rs using the load resistor (10 kΩ on most modules), and record Ro = Rs / 9.8 for the MQ-2 (the clean-air ratio from its datasheet; other sensors use other ratios).
  3. 3
    Use the curve for your gas to convert Rs/Ro into ppm. Libraries such as MQUnifiedsensor do this for you.

Expect ±30% at best. Temperature and humidity shift the readings, so a reading is an indicator, not a measurement.

05

Better sensors for real measurements

NeedUse instead
Real CO2 ppmSCD40 / SCD41 or MH-Z19 (NDIR)
Indoor air quality indexENS160, SGP40, BME688
Particulates (PM2.5)PMS5003, SPS30
Life-safety CO or gas alarmA certified standalone detector
NeedUse instead
Real CO2 ppm
SCD40 / SCD41 or MH-Z19 (NDIR)
Indoor air quality index
ENS160, SGP40, BME688
Particulates (PM2.5)
PMS5003, SPS30
Life-safety CO or gas alarm
A certified standalone detector
06

Try it: ADC resolution calculator

Change the values and the diagram and results update as you type.

07

Common mistakes to avoid

  • !Reading the sensor as soon as it is powered, before the heater stabilises.
  • !Powering the heater from 3.3 V, which gives weak and wrong readings.
  • !Feeding the 5 V analog output straight into an ESP32 pin.
  • !Treating the raw ADC value as ppm.
  • !Using an MQ sensor as the only protection against a gas leak.
08

Frequently asked questions

What does the MQ-2 sensor detect?

Smoke and flammable gases: LPG, propane, methane, hydrogen and alcohol vapour. It responds to all of them, so it cannot tell you which one.

What is the difference between MQ-2 and MQ-135?

MQ-2 targets flammable gases and smoke; MQ-135 targets air-quality pollutants such as ammonia, benzene and smoke, which makes it the usual choice for a rough indoor air-quality indicator.

How long does an MQ sensor take to warm up?

Readings settle after a few minutes, but a new sensor needs 24 to 48 hours of powered burn-in before values are repeatable.

Can an MQ sensor measure CO2?

Not reliably. The MQ-135 reacts to pollutants that often come with CO2 but does not measure CO2 itself. Use an NDIR sensor such as the SCD40 or MH-Z19.

Can I use MQ sensors with an ESP32?

Yes: power the heater from 5 V, and divide the analog output down to 3.3 V before the ADC pin.

Parts for this guide

SENS-3375ENS160+AHT21 Air Quality, Temperature & Humidity Sensor Module – I2CView productSENS-3453Asair AGS02MA MEMS TVOC Gas Sensor Module – Digital I2CView product
Shop Gas & Weather Sensors

Calculators

ADC resolution calculatorVoltage divider calculator

Terms in this guide

ppmParts per million. Used for gas concentration (outdoor CO2 is about 420 ppm) and for frequency accuracy: a 20 ppm crystal can drift about 1.7 seconds a day.Burn-inThe preheating period an MQ gas sensor needs (usually 24 to 48 hours the first time, minutes afterwards) before its readings settle.ComparatorA circuit that compares two voltages and outputs HIGH or LOW depending on which is larger. Sensor modules use one (often an LM393) to produce their digital output.Voltage dividerTwo resistors in series that output a fixed fraction of the input voltage.ADCAnalog-to-digital converter: turns a voltage into a number. A 10-bit ADC gives 0 to 1023; a 12-bit ADC gives 0 to 4095.NDIRNon-dispersive infrared: the accurate way to measure CO2 by absorption of infrared light, used by sensors such as the MH-Z19 and SCD40.

Projects that use it

Put this into practice: 48 step-by-step builds in our project library use parts from this guide.

Beginner · 1 hourAir-quality traffic-light ringView projectBeginner · 1 hourWorkshop dust and fume alarmView projectBeginner · 1 hourHow good is the air in our classroom?View project
Browse all 48 projects

Keep learning

ComparisonBeginnerDHT11 vs DHT22DHT11 vs DHT22 compared: accuracy, range and sampling rate, plus wiring, pull-up, Arduino/ESP32 code and when to pick a BME280 or SHT31.3 min read · SensorsHow-toIntermediate3.3 V vs 5 V LogicYou need level shifting when a 5 V device sends signals to a 3.3 V board such as an ESP32 or Raspberry Pi Pico, because 5 V on their pins can damage them.4 min read · Prototyping & WiringComponent guideBeginnerESP32 GuideThe ESP32 is a low-cost 3.3 V microcontroller from Espressif with built-in Wi-Fi and Bluetooth, used for IoT devices, smart-home controllers and web dashboards.5 min read · Boards & MicrocontrollersComponent guideBeginnerRelay ModulesA relay module is an electrically controlled switch that lets a microcontroller turn a separate circuit on or off, such as a 12 V pump or a mains lamp.4 min read · Switches, Relays & Input

Sources

  • MQ-2, MQ-7 and MQ-135 datasheets (Hanwei / Winsen)
  • MQUnifiedsensor library documentation

Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.

On this page
Short answerWhich MQ sensor do you need?How an MQ sensor worksWiring to Arduino and ESP32Getting a ppm estimateBetter sensors for real measurementsTry itCommon mistakesFAQsParts and next steps
Need a hand?Ask Geeko AI which part fits your project, or talk to the Geekobot team.Ask Geeko AIHelp & support
Run itChange the inputs and watch the output

Real sketch waits 20 s for the heater; here it starts at once.

A0 reading206
D0 LED OFF
Serial monitor9600 baud
Gas level: 206

A simulation of the sketch above, so you know what to expect. Real readings vary with your parts and wiring.

Ask the Community

Ask a question