Projects / Indoor air quality monitor with MQ-135

Indoor air quality monitor with MQ-135

Beginner1 hGuided buildReviewed

Build it step by step

0 of 5 done
  1. UNOMQ135808 ppm

    Burn in

    Power a new MQ-135 for 24 hours once, so its readings settle.

  2. UNO

    Wire the sensor

    VCC, GND, AO to A0.

  3. UNO15.8 mASSD1306

    Wire the OLED and LEDs

    OLED on A4/A5. LEDs with 220 Ω on D8, D9, D10.

  4. UNOMQ135810 ppm

    Start in fresh air

    Upload near an open window and let the 2-minute warm-up finish.

  5. UNO

    Test

    Hold a cotton ball with a drop of sanitiser near the sensor, then move it away.

In short

How do you build an indoor air quality monitor with MQ-135?

An MQ-135 gas sensor gives a relative air quality level on an OLED, with Good, Moderate and Poor bands against clean-air readings. You need Arduino Uno R3, MQ-135 air quality sensor module, SSD1306 OLED Display, LED 5 mm green, LED 5 mm yellow, LED 5 mm red, Resistor 220 Ω × 3, 5 V 2 A USB adapter and Jumper wires male to male (40 pcs, 20 cm). It takes 5 steps and about 60 minutes.

Level
Beginner
Time
About 60 min
Parts
9

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
MQ-135 VCC / GND / AOUno 5V / GND / A0Heater power and reading
OLED VCC / GND / SDA / SCLUno 5V / GND / A4 / A5Display
Uno D8 / D9 / D10220 Ω, green / yellow / red LEDGood / Moderate / Poor

Code

Arduino IDE, board "Arduino Uno". Install "Adafruit SSD1306" and "Adafruit GFX". Start it near an open window: the first reading is taken as clean air.

Runs on a virtual Arduino Uno in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

#include <Adafruit_SSD1306.h>

Adafruit_SSD1306 oled(128, 64, &Wire, -1);
const int GAS = A0, G = 8, Y = 9, R = 10;
float base = 0;

int readAvg() { long s = 0; for (int i = 0; i < 16; i++) { s += analogRead(GAS); delay(5); } return s / 16; }

void setup() {
  pinMode(G, OUTPUT); pinMode(Y, OUTPUT); pinMode(R, OUTPUT);
  oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  oled.setTextColor(SSD1306_WHITE);
  for (int s = 120; s > 0; s--) {           // 2 minutes warm-up in fresh air
    oled.clearDisplay(); oled.setCursor(0, 0); oled.print("Warming up "); oled.print(s); oled.display(); delay(1000);
  }
  base = readAvg();
}

void loop() {
  int v = readAvg();
  float ratio = v / base;                    // 1.0 = as clean as at start-up
  const char* band = ratio < 1.25 ? "Good" : ratio < 1.6 ? "Moderate" : "Poor";
  digitalWrite(G, ratio < 1.25); digitalWrite(Y, ratio >= 1.25 && ratio < 1.6); digitalWrite(R, ratio >= 1.6);
  oled.clearDisplay(); oled.setTextSize(1); oled.setCursor(0, 0); oled.print("Air quality");
  oled.setTextSize(2); oled.setCursor(0, 18); oled.print(band);
  oled.setTextSize(1); oled.setCursor(0, 48); oled.print("x"); oled.print(ratio, 2); oled.print(" of clean air");
  oled.display();
  delay(1000);
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
After warm-up in fresh air"Good", ratio about 1.00
Sanitiser or incense nearbyRatio rises above 1.6, "Poor", red LED
A closed room with several people for an hourOften "Moderate"

If it does not work

Starts at Poor

It was started in stale air. Restart next to an open window.

Numbers drift through the day

Metal-oxide sensors change with temperature and humidity. This shows trends, not exact gas levels.

Need real numbers

For CO₂ in ppm, use the SCD40 build. For dust, use the PMS5003 build.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the indoor air quality monitor with MQ-135?

Arduino Uno R3, MQ-135 air quality sensor module, SSD1306 OLED Display, LED 5 mm green, LED 5 mm yellow, LED 5 mm red, Resistor 220 Ω × 3, 5 V 2 A USB adapter and Jumper wires male to male (40 pcs, 20 cm).

How long does the indoor air quality monitor with MQ-135 take to build?

About 60 minutes for a beginner maker, in 5 steps.

How do I know the indoor air quality monitor with MQ-135 works?

After warm-up in fresh air: "Good", ratio about 1.00. Sanitiser or incense nearby: Ratio rises above 1.6, "Poor", red LED. A closed room with several people for an hour: Often "Moderate".

Starts at Poor: what should I check?

It was started in stale air. Restart next to an open window.

Numbers drift through the day: what should I check?

Metal-oxide sensors change with temperature and humidity. This shows trends, not exact gas levels.

Need real numbers: what should I check?

For CO₂ in ppm, use the SCD40 build. For dust, use the PMS5003 build.