Interfacing of MQ-135 Gas Sensor with Arduino



Interfacing of MQ-135 Gas Sensor with ArduinoIn today’s world, we encounter different scenario where we see different gasses being emitted in atmosphere such as home appliances like air conditioner and industrial chimneys. Monitoring of these gasses is very important with safety point of view. Gas Sensors are very helpful in accomplishing this task. Small nose like sensor spontaneously respond to the alteration of gas concentration and keep our systems updated for special tasks.



In this tutorial we will learn how to interface MQ-135 Gas Sensor with Arduino Board? We will explore what is Gas Sensor? How it works? What is its pin configuration and how to interface it with Arduino? Our today’s tutorial consists of following sections:

  • What is MQ-135 and how does it work?
  • Pin Configuration.
  • Required Components.
  • Wiring Connections.
  • Testing the Circuit.
  • Code for Arduino.

What is MQ-135 gas sensor and how does it work?

The gas sensor module consists of a steel exoskeleton under which a sensing element is housed. This sensing element is subjected to current through connecting leads. This current is known as heating current through it, the gases coming close to the sensing element get ionized and are absorbed by the sensing element. This changes the resistance of the sensing element which alters the value of the current going out of it.



Pin Configuration MQ-135 gas sensor

From left to right first pins are as follows:

A0        Analog output

D0        Digital output

GND     Ground

Vcc      Supply (5V)

Specifications of MQ-135 gas sensor

  • Wide detecting scope
  • Fast response and High sensitivity
  • Stable and long life Simple drive circuit
  • Used in air quality control equipment for buildings/offices, is suitable for detecting
    of NH3, NOx, alcohol, Benzene, smoke, CO2, etc.
  • Size: 35mm x 22mm x 23mm (length x width x height)
  • Working voltage: DC 5 V
  • Signal output instruction.
  • Dual signal output (analog output, and high/low digital output)
  • 0 ~ 4.2V analog output voltage, the higher the concentration the higher the voltage.

Required Components:

Following Components are required for this project:

  • Arduino UNO
  • Breadboard
  • MQ-2 Gas sensor module

interfacing of MQ-135 gas sensor with Arduino

Wire the circuit as follows:

Arunio A0 pin              with                 Sensor A0

Aruino D0 pin              with                 Sensor D0

Arduino 5Vpin             with                 Sensor Vcc

Arduino GND pin         with                 Sensor GNDInterfacing of MQ-135 Gas Sensor with Arduino

When no gas digital output is 1 and analog output gives 1023 max value. When gas is present digital output is 0 and analogue output is much less than 1023. Using potentiometer on chip we can control the turning OFF point of digital pin at some value of analog pin. The sensor needs a load-resistor at the output to ground. Its value could be from 2kOhm to 47kOhm. The lower the value, the less sensitive is the sensor. The higher the value, the less accurate is sensor for higher concentrations of gas. If only one specific gas is measured, the load-resistor can be calibrated by applying a known concentration of that gas. If the sensor is used to measure any gas (like in a air quality detector) the load-resistor could be set for a value of about 1V output with clean air. Choosing a good value for the load-resistor is only valid after the burn-in time

NOTE: Don’t touch the sensor, it will be very hot.

Testing the Circuit:

  1. After hardware connection, insert the sample sketch into the Arduino IDE.
  2. Using a USB cable, connect the ports from the Arduino to the computer.
  3. Upload the program.
  4. See the results in the serial monitor.

Code for interfacing of MQ-135 gas sensor with Arduino

int sensorValue;

int digitalValue;

void setup()

{

  Serial.begin(9600);      // sets the serial port to 9600

  pinMode( 0, INPUT);

}




void loop()

{

  sensorValue = analogRead(0);       // read analog input pin 0

  digitalValue = digitalRead(0); 

  Serial.println(sensorValue, DEC);  // prints the value read

  Serial.println(digitalValue, DEC);

  delay(2000);                        // wait 100ms for next reading

}

Result:

On serial monitor you can see values of analog pin being detected. Currently in my case they are around about 150 which indicate normal air.

  • Normal air returns approximately 100-150
  • Alcohol returns approximately 700
  • Lighter gas returns approximately 750



One Response

  1. Deeksha K May 30, 2017

Add Comment

Subscribe to our blog to get updates in your email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,395 other subscribers