MQ-135 Gas Detection Tutorial

Gas Detection using MQ-135 Sensor

Objective

The objective of this experiment is to learn how to detect gases such as ammonia, benzene, and carbon dioxide using the MQ-135 gas sensor. We will explore the sensor's working principle, wiring instructions, and how to use Arduino to measure and interpret gas concentration data. This project is suitable for air quality monitoring and safety systems.

By the end of this tutorial, you will understand how to integrate sensors with Arduino for environmental monitoring and have a foundation for expanding into advanced applications.

Required Components

Optional: A 10k-ohm resistor and a multimeter can be used to calibrate the sensor for specific gases if needed.

Working Principle

The MQ-135 gas sensor uses a chemical-sensitive layer that changes its electrical resistance when exposed to certain gases. It detects gases by converting changes in resistance to a measurable voltage, which can be read as an analog signal by the Arduino.

The sensor has a built-in heating element that helps stabilize the chemical layer for more accurate readings. The output signal corresponds to the concentration of gases like ammonia (NH3), benzene (C6H6), carbon dioxide (CO2), and more.

Note: The MQ-135 sensor is sensitive to multiple gases, but it does not differentiate between them. Calibration is necessary to detect specific gas concentrations accurately.

Circuit Wiring Instructions

To set up the MQ-135 gas sensor with your Arduino, follow these detailed wiring steps:

  1. Connect the VCC Pin: Use a jumper wire to connect the VCC pin of the MQ-135 sensor to the 5V pin on the Arduino. This provides power to the sensor.
  2. Connect the GND Pin: Attach the GND pin on the MQ-135 sensor to the GND pin on the Arduino. This creates a common ground for both components.
  3. Connect the A0 Pin: Connect the A0 pin of the sensor to the analog pin A0 on the Arduino. This pin sends the gas concentration data to the Arduino.

Tips:

Arduino Code


/*
 * Gas Detection using MQ-135 Sensor
 * This code reads the gas concentration from the MQ-135 sensor and displays it on the serial monitor
 */

const int mq135Pin = A0;  // MQ-135 sensor connected to analog pin A0
int gasLevel = 0;

void setup() {
    Serial.begin(9600);  // Initialize serial communication
    Serial.println("MQ-135 Gas Sensor Test");
}

void loop() {
    // Read the value from the MQ-135 sensor
    gasLevel = analogRead(mq135Pin);

    // Print the gas level to the serial monitor
    Serial.print("Gas Level: ");
    Serial.println(gasLevel);

    // Add a simple threshold for gas detection
    if (gasLevel > 400) {
        Serial.println("Warning: High Gas Concentration Detected!");
    }

    delay(1000);  // Wait for 1 second
}
        

Explanation: This code reads the analog value from the sensor and displays it on the serial monitor. You can add thresholds to trigger alarms or other actions based on gas levels.

Results

After uploading the code to the Arduino, open the Serial Monitor (Ctrl+Shift+M in the Arduino IDE). You will see the gas level values updating every second. Higher gas concentrations result in higher values displayed in the serial monitor.

For example:

Applications

Advanced Applications: By calibrating the MQ-135 sensor and integrating it with wireless modules, you can create IoT-based gas detection systems.

Conclusion

The MQ-135 sensor is a powerful and versatile tool for detecting gases in various applications. This tutorial provided a step-by-step guide to wire the sensor, upload Arduino code, and observe real-time gas concentration data.

With proper calibration, this sensor can be a critical component in systems for air quality monitoring, industrial safety, and environmental research. Experiment further by adding displays or alarms for a complete gas detection system.