Monitor Air Quality with Arduino!
- Cartell Automotive
- Jul 8
- 3 min read
Introduction
In this beginner-friendly Arduino project, we’ll build a simple air quality monitor using the MQ135 gas sensor, the DHT11 temperature and humidity sensor, and a 16x2 LCD to display the live data. Whether you’re concerned about indoor air pollution or just curious, this setup is a great starting point.

Components Needed
Arduino Uno (or Nano)
MQ135 Air Quality Sensor
DHT11 Temperature and Humidity Sensor
16x2 LCD (with I2C module preferred)
Breadboard + Jumper Wires
USB cable for programming
Component | Arduino Pin |
MQ135 VCC | 5V |
MQ135 GND | GND |
MQ135 A0 | A0 |
DHT11 VCC | 5V |
DHT11 GND | GND |
DHT11 DATA | D2 |
LCD VCC (I2C) | 5V |
LCD GND (I2C) | GND |
LCD SDA | A4 |
LCD SCL | A5 |
Arduino Code
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>
// Setup LCD
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Setup DHT11
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
// MQ135 analog pin
const int mq135Pin = A0;
void setup() {
Serial.begin(9600);
dht.begin();
lcd.begin();
lcd.backlight();
}
void loop() {
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
int airQuality = analogRead(mq135Pin);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("T:");
lcd.print(temperature);
lcd.print(" H:");
lcd.print(humidity);
lcd.setCursor(0, 1);
lcd.print("Air:");
lcd.print(airQuality);
delay(2000);
}What Do the Readings Mean?
Air Quality Value: The MQ135 gives a general analog reading, higher values may indicate poor air quality (e.g., CO2, ammonia, benzene).
Temperature & Humidity: These help correlate air quality with environmental conditions.
Can the MQ135 measure in PPM?
Yes, but it needs calibration. The sensor outputs an analog voltage, which you read via analogRead(). To convert this to PPM, you need to:
Determine the sensor resistance (Rs) at a given concentration.
Compare Rs to the baseline resistance (Ro) in clean air.
Use the logarithmic curve from the datasheet to estimate PPM.
The datasheet gives you:
Rs/Ro curves for different gases (e.g., NH₃, CO₂, benzene)
Rs is the sensor resistance in the target gas
Ro is the resistance in clean air
The relationship is roughly:
log(Rs/Ro)vs.log(PPM)log(Rs/Ro) vs. log(PPM) log(Rs/Ro)vs.log(PPM)
So for each gas:
You plot the measured Rs/Ro
Use the relevant graph to find approximate PPM
Limitations
You can’t get accurate readings without controlled gas samples for calibration.
It detects multiple gases, so the PPM reading might not be specific (e.g., high CO₂ could be confused with high NH₃).
It’s useful for relative changes in air quality, rather than precise readings.
As per the datasheet:
"When target pollution gas exists, the sensor’s conductivity gets higher along with the gas concentration rising. Users can convert the change of conductivity to correspond output signal of gas concentration"
Bonus Tips
Place the MQ135 away from fans or vents for stable readings.
For better accuracy, let the MQ135 warm up for a few minutes after powering on.
Calibrate your sensor values using known good/bad air environments.
As from the community
This is what you could expect:
Air Condition | Analog Value (A0) | Rs/Ro Estimate | Notes |
Clean outdoor air | 150–200 | ~1.0 | Baseline / calibrate Ro |
Indoor average | 250–350 | 0.5–0.8 | Poorer air quality |
Polluted area / VOCs | 400–600+ | <0.5 | Very poor air |
Close to alcohol/gas | 700–900+ | << 0.4 | Strong response |
Here's a cheat sheet if you need it
Sensor Types and what they detect:
Sensor | Detects | Notes |
MQ-2 | Smoke, LPG, Butane, Propane, Methane, Alcohol, Hydrogen | General gas and smoke sensor, very common |
MQ-3 | Alcohol, Ethanol, Benzine | Breathalyzer projects, sensitive to alcohol vapors |
MQ-4 | Methane, Natural Gas | Used in methane/NG leak detectors |
MQ-5 | LPG, Natural Gas, Town Gas | Wider range gas detector than MQ-4 |
MQ-6 | LPG, Butane, Propane | Good for cooking gas leak detection |
MQ-7 | Carbon Monoxide (CO) | Needs heating cycles for accurate CO readings |
MQ-8 | Hydrogen (H₂) | Useful for hydrogen leak detection |
MQ-9 | Carbon Monoxide (CO), Methane (CH₄), LPG | Dual gas detection, with heating cycles |
MQ-135 | Air Quality: CO₂, NH₃, Alcohol, Benzene, Smoke, VOCs | Good general indoor air quality sensor |
MQ-136 | Hydrogen Sulfide (H₂S) | Toxic gas monitoring |
MQ-137 | Ammonia (NH₃) | Focused on industrial ammonia detection |
MQ-138 | Benzene, Alcohol, Ammonia, VOCs | High VOC sensitivity, useful for pollution sensors |
Maybe try the following as your own exercise and produce the code:

Have fun! Share your findings in the comments.




Comments