Sep 21, 2016

MQ-135 Air Quality Sensor with Arduino

In this article we are going to learn how to interface air quality sensor MQ-135 with Arduino. We will see overview of the sensor and construct a project which detects LPG gas leakage and see some relevant readings in serial monitor.


By: Girish Radhakrishnan

What is MQ-135 sensor?


MQ-135 is an air quality or air pollution measuring sensor device. It can detect various chemical contents in air and give appropriate voltage variation at the output pin depending on the chemical concentration in air.

It can detect alcohol, Benzene, smoke, NH3, butane, propane etc. if anyone of the stated chemical concentration rises, the sensor convert the chemical concentration in air to appropriate voltage range, which can be processed by Arduino or any microcontroller. It cannot tell what kind of chemical concentration rose in the air.

Typical MQ-135 sensor:


how to interface air quality sensor MQ-135 with Arduino


It is 6 terminal device which is symmetric in terminal placement; both the sides of the terminal are interchangeable. Here is the illustration of pins:



Here is a basic connection diagram:



Two ‘A’ pins are shorted internally and two ‘B’ pins are shorted internally. H and H pins is heater coil of the sensor. The heater coil is used to heat up the air around the sensor, so that it can detect the chemical content in the air optimally.

The sensor can take up to few minutes to heat up to reach optimal working condition. It not advisable to touch the sensor while operating because it can get pretty warm.

The sensor has an operating voltage of 5V; the sensor must be powered from external sources only, as it consumes about 200mA for heating. The arduino voltage regulator can’t deliver this much current.

For testing, you can connect a ammeter in mA range at the output pin B and bring a cigar gas lighter. Try to leak the gas without igniting it near the sensor. As the concentration of gas rises around the sensor, the current flow through ammeter increases. If this works, your sensor is working normally.

Now, you know quite a bit about MQ-135 Sensor, let’s move ahead and learn how to interface the MQ-135 with Arduino interfacing.

The circuit:




air quality sensor MQ-135 with Arduino


Make the connections as per the diagram, and check the gas sensor wire connection etc. Rest of the circuit is self explanatory.

The analogue pin of Arduino measures the voltage from the gas sensor. When the gas concentration rises above preset threshold in the program, the buzzer starts beeps.

The sensor takes a couple of minutes or so to warm up to reach optimal operating condition. Until it reaches optimal working temperature, the values in the serial monitor fluctuates high and low. It stabilizes after few minutes.

In the program the user can set the threshold value, it must be done only after careful observation on normal ambient concentration value in the serial monitor.  For instants, if the value fluctuates from 400 to 430, the threshold must set well above, like 500. It must not trigger the buzzer falsely.

The values displayed in the serial monitor are NOT ‘ppm’ level of chemical concentration or anything like that. It is mere measure of voltage level from the sensor; Arduino interprets the value from 0 to 1023. So we can say, higher the chemical concentration, higher the values get displayed.

Program:

//-------------------Program Developed by R.Girish-----------------//
int input = A0;
int output = 7;
int th=500;   // Set threshold level.
void setup()
{
  Serial.begin(9600);
  pinMode(output,OUTPUT);
  digitalWrite(output,LOW);
}
void loop()
{
  Serial.println(analogRead(input));
  if(analogRead(input)>th)
  {
    digitalWrite(output,HIGH);
  }
  else
  {
    digitalWrite(output,LOW);
  }
    delay(500);
}

//-------------------Program Developed by R.Girish-----------------//

The serial monitor is not mandatory in this project it also works as standalone; we need it only to calibrate the threshold value in the program.

Set the threshold value by changing:

int th=500;   // Set threshold level.

Replace 500 with your value.

This concludes the article regarding how to interface MQ-135 air quality sensor with Arduino, for further queries you can post your thoughts through your comments.

Hi Friends, Welcome to my site, a place where you will discover a massive collection of electronic circuit ideas, mostly requested by the dedicated readers and exclusively designed by me for their customized application needs. I have posted more than 1100 circuit designs in this site, if you have a personalized circuit requirement you may feel free to request it through the comment box, if it seems feasible to me then surely you may find it published here with your credentials attached in the post, thanks and please keep reading

7 comments:

  1. sir can i substituate NPN transistor with any NPN transistor even if ther values are not the same ?

    ReplyDelete
    Replies
    1. yes you can, but preferably their main specs should be similar.

      Delete
  2. sir if i want connect transistor six TIP35C in pararell may i going to connect based to based emitter to emitter collector to collector ?

    ReplyDelete
    Replies
    1. Bashir, that's possible but make sure to connect all the transistors over a common heatsink

      you can refer the following article for more help

      http://www.homemade-circuits.com/2011/11/transistor-facts.html

      Delete
  3. Thank u sir. and my another question is that can any inverter work with any transformer like 6-0-6, 12-0-12 and so on according to watt i require and i know if i used 6-0-6 transformer the battery must be 6v the same with 12-0-12 battery must be 12v Sir may i correct or not ?

    ReplyDelete
    Replies
    1. Bashir, all transformers can be used for inverter application, but the operating voltage needs to be approximately equal to its primary winding voltage rating...so a 6-0-6 will require a 6V batt, a 12-0-12 will require a 12V batt and so on

      Delete