• Skip to main content
  • Skip to primary sidebar

Homemade Circuit Projects

Get free circuit help 24/7

New Projects | Privacy Policy | About us | Contact | Disclaimer | Copyright | Videos | Circuits for Beginners | Basic Circuits | Hobby Projects | Transistor Circuits | LED Drivers 

You are here: Home / Sensors and Detectors / MQ-135 Air Quality Sensor Circuit – Working and Interfacing with Program Code

MQ-135 Air Quality Sensor Circuit – Working and Interfacing with Program Code

Last Updated on August 9, 2019 by Swagatam 17 Comments

caution electricity can be dangerous

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.

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:

MQ135 air quality sensor module

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:

MQ135 pinouts

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:

Arduino MQ-135 Air Quality Sensor Working and Interfacing

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.

You'll also like:

  • 1.  3 Easy Capacitive Proximity Sensor Circuits Explored
  • 2.  Simple LDR Motion Detector Alarm Circuit
  • 3.  Proximity Detector IC CS209A Pinouts – Datasheet Explained
  • 4.  Motion Detector Circuit using Doppler Effect
  • 5.  7 Best Touch Sensor Switch Circuits Explored
  • 6.  Simple Peak Detector to Detect and Hold Peak Voltage Levels

About Swagatam

I am an electronic engineer (dipIETE ), hobbyist, inventor, schematic/PCB designer, manufacturer. I am also the founder of the website: https://www.homemade-circuits.com/, where I love sharing my innovative circuit ideas and tutorials.
If you have any circuit related query, you may interact through comments, I'll be most happy to help!

Have Questions? Please Comment below to Solve your Queries! Comments must be Related to the above Topic!!

Subscribe
Notify of
17 Comments
Newest
Oldest
Inline Feedbacks
View all comments

Primary Sidebar

Calculators

  • 3-Phase Power (15)
  • 324 IC Circuits (19)
  • 4017 IC Circuits (52)
  • 4060 IC Circuits (25)
  • 555 IC Circuits (98)
  • 741 IC Circuits (19)
  • Arduino Engineering Projects (83)
  • Audio and Amplifier Projects (114)
  • Battery Chargers (82)
  • Car and Motorcycle (94)
  • Datasheets (46)
  • Decorative Lighting (Diwali, Christmas) (33)
  • Electronic Components (100)
  • Electronic Devices and Circuit Theory (36)
  • Electronics Tutorial (116)
  • Fish Aquarium (5)
  • Free Energy (34)
  • Fun Projects (13)
  • GSM Projects (9)
  • Health Related (20)
  • Heater Controllers (29)
  • Home Electrical Circuits (102)
  • How to Articles (20)
  • Incubator Related (6)
  • Industrial Electronics (28)
  • Infrared (IR) (40)
  • Inverter Circuits (98)
  • Laser Projects (12)
  • LED and Light Effect (93)
  • LM317/LM338 (21)
  • LM3915 IC (25)
  • Meters and Testers (65)
  • Mini Projects (148)
  • Motor Controller (67)
  • MPPT (7)
  • Oscillator Circuits (26)
  • PIR (Passive Infrared) (8)
  • Power Electronics (34)
  • Power Supply Circuits (77)
  • Radio Circuits (10)
  • Remote Control (48)
  • Security and Alarm (61)
  • Sensors and Detectors (120)
  • SG3525 IC (5)
  • Simple Circuits (75)
  • SMPS (29)
  • Solar Controllers (60)
  • Timer and Delay Relay (53)
  • TL494 IC (5)
  • Transformerless Power Supply (8)
  • Transmitter Circuits (40)
  • Ultrasonic Projects (16)
  • Water Level Controller (45)

Calculators

  • AWG to Millimeter Converter
  • Battery Back up Time Calculator
  • Capacitance Reactance Calculator
  • IC 555 Astable Calculator
  • IC 555 Monostable Calculator
  • Inductance Calculator
  • LC Resonance Calculator
  • LM317, LM338, LM396 Calculator
  • Ohm’s Law Calculator
  • Phase Angle Phase Shift Calculator
  • Power Factor (PF) Calculator
  • Reactance Calculator
  • Small Signal Transistor(BJT) and Diode Quick Datasheet
  • Transistor Astable Calculator
  • Transistor base Resistor Calculator
  • Voltage Divider Calculator
  • Wire Current Calculator
  • Zener Diode Calculator

© 2023 · Swagatam Innovations

wpDiscuz