Indoor air quality monitor with MQ-135
Build it step by step
0 of 5 doneBurn in
Power a new MQ-135 for 24 hours once, so its readings settle.
Wire the sensor
VCC, GND, AO to A0.
Wire the OLED and LEDs
OLED on A4/A5. LEDs with 220 Ω on D8, D9, D10.
Start in fresh air
Upload near an open window and let the 2-minute warm-up finish.
Test
Hold a cotton ball with a drop of sanitiser near the sensor, then move it away.
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
- Development BoardsBuyArduino Uno R3 × 1
- SensorsBuy
- DisplaysBuy
- SemiconductorsBuyLED 5 mm green × 1
- SemiconductorsBuyLED 5 mm yellow × 1
- SemiconductorsBuyLED 5 mm red × 1
- PassivesBuyResistor 220 Ω × 3
- PowerBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| MQ-135 VCC / GND / AO | Uno 5V / GND / A0 | Heater power and reading |
| OLED VCC / GND / SDA / SCL | Uno 5V / GND / A4 / A5 | Display |
| Uno D8 / D9 / D10 | 220 Ω, green / yellow / red LED | Good / 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.
| Check | Expected |
|---|---|
| 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" |
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 →
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.
