Description
The MQ-135 Air Quality Sensor is designed for detecting gases such as ammonia (NH3), benzene, sulfur dioxide (SO2), alcohol, carbon dioxide (CO2), smoke, and other pollutants in the air. With a detection range of 10-300 ppm, this sensor is useful for monitoring air quality. It has both analog and digital outputs and operates on a 5V DC power supply.
Getting Started with the MQ-135 Air Quality Sensor and Arduino
The MQ-135 Air Quality Sensor is designed for detecting gases such as ammonia (NH3), benzene, sulfur dioxide (SO2), alcohol, carbon dioxide (CO2), smoke, and other pollutants in the air. With a detection range of 10-300 ppm, this sensor is useful for monitoring air quality. It has both analog and digital outputs and operates on a 5V DC power supply.
Features
- Power Supply: 5V DC
- Outputs: Analog and TTL-compatible digital output
- Connection: 4-pin header for power and outputs
- Status Indicators: LEDs for power and output
- Detection Range: 10-300 ppm
Hardware Requirements
- Arduino Uno
- Air Quality Sensor (MQ-135)
- Jumper wire
Step 1: Wiring Connections
Connect the MQ-135 sensor to the Arduino as follows:
Arduino Uno Pin | MQ-135 Pin |
---|---|
Vcc | Vcc |
GND | GND |
A0 | A0 |
Step 2: Basic Code to Read Air Quality
This code will read the analog output from the sensor’s A0 pin and display the air quality readings in the Arduino Serial Monitor.
int airQuality = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(A0);
Serial.print("Air Quality = ");
Serial.print(sensorValue);
Serial.println(" *PPM");
delay(1000);
}
Upload the code to your Arduino and open the Serial Monitor to view the air quality readings. The sensor’s output value increases as air quality decreases.
Step 3: Get Separate Gas Values
To obtain individual gas concentrations, use the MQUnifiedsensor library. This library provides a more detailed breakdown of various gases detected by the MQ-135 sensor.
- Install the MQUnifiedsensor library from the Arduino Library Manager.
- Load the example file:
- Go to File > Examples > MQUnifiedsensor > MQ-135-All.
- If using an ESP8266, change the “placa” variable from “Arduino UNO” to “ESP8266”.
- Upload the code and monitor the serial output for specific gas readings.