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-135 air quality sensor

Component guide · Beginner · 3 min read

MQ-135 air quality sensor

Pinout, Wiring and Code

By Geekobot Learning Team · Updated 29 Oct 2026

I'm using
Wiring, code and the Run it panels follow your board.
On this page
Short answerWhat the MQ-135 air quality sensor isMQ-135 air quality sensor pinoutWiring the MQ-135 air quality sensorExample codeSetup and tuningWhat you needAlternatives and when to choose themTry itCommon mistakesFAQsParts and next steps
Short answer

The MQ-135 is a heated gas sensor that responds to ammonia, benzene, alcohol, smoke and other pollutants, so its analog output works as a general indoor air quality indicator. It needs 5 V, about 150 mA and a warm-up period. It is not a real CO2 sensor: for accurate CO2 use an NDIR sensor such as the MH-Z19 or SCD40.

Key specs at a glance

Detects
NH3, NOx, alcohol, benzene, smoke, CO2 (weak response)
Range
About 10 to 1000 ppm for ammonia and benzene (needs calibration)
Heater
5 V, about 150 mA
Outputs
AO analog, DO digital with trimmer threshold
Warm-up
Minutes for use, 24 to 48 hours burn-in for new sensors
Supply
5 V

Models in this guide

These are alternatives. Pick the one that fits your project; you only need one.

  • Option 1MQ-135 Air Quality & Gas Detector Sensor Module for Arduino – Analog & TTL Output₹114
  • Option 2MQ-135 Air Quality Sensor Harmful Gas Detection Module – Analog & Digital Output₹114
  • Option 3Waveshare MQ-135 Air Quality Gas Sensor Module – Analog/Digital Output₹459
  • Option 4Winsen MQ135 Semiconductor Air Quality Sensor – SnO2 Gas Detection Module₹239
01

What the MQ-135 air quality sensor is

Like the MQ-2, the MQ-135 is a heated tin dioxide sensor whose resistance drops in the presence of certain gases. Its material is tuned toward air pollutants, which makes it a popular cheap air quality indicator for classrooms and kitchens.

Many tutorials print a CO2 ppm number from it. That number is an estimate based on assumptions; the sensor reacts much more strongly to other gases, so use it as an index, not a measurement.

02

MQ-135 air quality sensor pinout

The pins on the MQ-135 air quality sensor and what each one does.

PinFunction
VCC5 V
GNDGround
AOAnalog output, higher = more pollutants
DODigital alarm output (trimmer threshold)
PinFunction
VCC
5 V
GND
Ground
AO
Analog output, higher = more pollutants
DO
Digital alarm output (trimmer threshold)
03

Wiring the MQ-135 air quality sensor

Scale AO with a divider before an ESP32 pin. Keep the sensor away from the board's regulator so its heat does not affect other sensors.

MQ-135 air quality sensor pinArduino UnoESP32
VCC5V5V (VIN)
GNDGNDGND
AOA0GPIO 34 via 10k/20k divider
DOD2GPIO 27
VCC
Arduino Uno:
5V
ESP32:
5V (VIN)
GND
Arduino Uno:
GND
ESP32:
GND
AO
Arduino Uno:
A0
ESP32:
GPIO 34 via 10k/20k divider
DO
Arduino Uno:
D2
ESP32:
GPIO 27
04

Example code

The thresholds are examples. Record values in fresh outdoor air and in your room to set your own levels.

Air quality index with a moving average · Arduino C++Verify & upload in Electrolark
const int AO_PIN = A0;
float avg = 0;

void setup() {
  Serial.begin(9600);
  delay(120000);                    // 2 minute warm-up
  avg = analogRead(AO_PIN);
}

void loop() {
  avg = avg * 0.9 + analogRead(AO_PIN) * 0.1;   // smooth the reading
  const char* level = avg < 200 ? "good" : avg < 350 ? "moderate" : "poor";
  Serial.print((int)avg); Serial.print("  "); Serial.println(level);
  delay(1000);
}
05

Setup and tuning

Baseline in fresh air

after burn-in, note the reading outdoors or by an open window. Compare indoor values against it.

Humidity and temperature

change the reading; pair it with an AHT20 if you want to compensate.

Library ppm values

(MQ135 library) use a reference resistance R0 that you must calibrate; without it the numbers are not meaningful.

Ventilation reminders

a rising trend over an hour is a good trigger to open a window.

06

What you need

Shop this list6 of 6 found in our store · ₹1,454

  • MQ-135 air quality and gas detector module: the common moduleMQ-135 Air Quality & Gas Detector Sensor Module for Arduino – Analog & TTL Output₹114
  • MQ-135 harmful gas detection module: alternative boardMQ-135 Air Quality Sensor Harmful Gas Detection Module – Analog & Digital Output₹114
  • Waveshare MQ-135 air quality gas sensor: Waveshare boardWaveshare MQ-135 Air Quality Gas Sensor Module – Analog/Digital Output₹459
  • Winsen MQ135 air quality sensor: the original maker's sensorWinsen MQ135 Semiconductor Air Quality Sensor – SnO2 Gas Detection Module₹239
  • ESP32-WROOM-32 38-pin development board: for Wi-Fi logging and dashboardsESP32-WROOM-32 38-Pin Development Board₹389
  • 0.96 inch OLED display 128x64: to show readings without a computer0.96" OLED Display 128x64₹139Closest match, check the specs
07

Alternatives and when to choose them

  • ✓CO2 NDIR sensors: MH-Z19, SCD40 for real CO2 ppm.
  • ✓VOC sensors: SGP30, ENS160 with digital output.
  • ✓PM2.5 dust sensors: for smoke and dust particles.
08

Try it: Voltage divider calculator

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

09

Common mistakes to avoid

  • !Treating its output as accurate CO2 ppm.
  • !Reading before warm-up.
  • !Powering the heater from a 3.3 V pin.
  • !Mounting it inside a closed box with the controller.
10

Frequently asked questions

Can the MQ-135 measure CO2?

Only roughly. It responds more strongly to other gases; use an NDIR sensor for real CO2 values.

What does a higher reading mean?

More pollutants such as ammonia, alcohol, smoke or benzene in the air.

How long is the warm-up?

A few minutes for use; a new sensor needs 24 to 48 hours of burn-in.

Does it work with ESP32?

Yes, powered from 5 V with the analog output scaled to 3.3 V.

MQ-135 or MQ-2?

MQ-135 for air quality, MQ-2 for flammable gas and smoke.

Why does the reading drift?

Temperature, humidity and sensor ageing. Re-check the clean-air baseline regularly.

Parts for this guide

  • MQ-135 Air Quality & Gas Detector Sensor Module for Arduino – Analog & TTL Output
    ₹114View
  • MQ-135 Air Quality Sensor Harmful Gas Detection Module – Analog & Digital Output
    ₹114View
  • Waveshare MQ-135 Air Quality Gas Sensor Module – Analog/Digital Output
    ₹459View
  • Winsen MQ135 Semiconductor Air Quality Sensor – SnO2 Gas Detection Module
    ₹239View
  • ESP32-WROOM-32 38-Pin Development Board
    ₹389View
  • 0.96" OLED Display 128x64
    ₹139View
Shop Gas, Air Quality & CO2 Sensors

Calculators

Voltage divider calculator

Terms in this guide

Burn-inThe preheating period an MQ gas sensor needs (usually 24 to 48 hours the first time, minutes afterwards) before its readings settle.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.

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

Component guideIntermediateMQ Gas SensorsMQ sensors are cheap metal-oxide gas sensors: a heated tin-dioxide surface changes resistance when gas is present.3 min read · SensorsBuying guideIntermediateAir Quality SensorsCompare particle, CO2 and VOC sensors for an air monitor: PMS5003 and SDS011, NDIR CO2 vs eCO2, wiring, warm-up, power and placement for honest readings.3 min read · SensorsComparisonIntermediateCO2 SensorsCO2 sensors tell you when a room needs fresh air: outdoors is about 420 ppm, under 1000 ppm indoors is good and above 1500 ppm calls for ventilation.3 min read · SensorsComparisonIntermediateVOC and Indoor Air Quality SensorsVOC sensors detect a mix of organic gases from cleaners, paints and cooking and report a relative index rather than a precise gas amount.3 min read · Sensors

Sources

  • MQ-135 gas sensor technical data (Hanwei / Winsen)

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

On this page
Short answerWhat the MQ-135 air quality sensor isMQ-135 air quality sensor pinoutWiring the MQ-135 air quality sensorExample codeSetup and tuningWhat you needAlternatives and when to choose themTry 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

Parts for this guide (Arduino Uno)2 items · ₹318

MQ-135 Air Quality & Gas Detector Sensor Module for Arduino – Analog & TTL Output · Uno R3 CH340G ATmega328p Compatible Development Board

Run itChange the inputs and watch the output

The reading is smoothed (90% old, 10% new), so it moves slowly when you change the air.

Serial monitor9600 baud
206  moderate

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