MQ135 Gas Sensor

Gas Sensor with MQ135

Introduction

The MQ135 gas sensor is used for detecting gases like ammonia, carbon dioxide, and alcohol. It is commonly used in air quality monitoring systems.

MQ135 Gas Sensor

Components Needed

Circuit Setup

  1. Connect the VCC pin of the MQ135 to the 5V pin on the Arduino.
  2. Connect the GND pin to the GND pin on the Arduino.
  3. Connect the analog output pin of the MQ135 to an analog input pin (e.g., A0) on the Arduino.

Ensure the sensor is connected properly for accurate readings.

MQ135 Gas Sensor Circuit Setup

Code for Gas Sensor

Upload the following code to your Arduino to read the gas levels:


const int gasPin = A0;  // Pin connected to the MQ135 sensor
int gasValue = 0;

void setup() {
  Serial.begin(9600);
}

void loop() {
  gasValue = analogRead(gasPin);
  Serial.print("Gas Level: ");
  Serial.println(gasValue);
  delay(500);
}
            

Explanation

The code reads the analog value from the gas sensor and outputs it to the serial monitor. Higher values indicate higher gas concentrations, which can be interpreted based on the specific gas being detected.

Troubleshooting