How MQ2 Gas/Smoke Sensor Works? & Interface it with Arduino

The next Arduino project a nose for gasses with the MQ2 Gas Sensor Module. This is a powerful Gas sensor suitable for detecting LPG, Smoke, Alcohol, Propane, Hydrogen, Methane and Carbon Monoxide concentrations in the air. If you want to creating an indoor air quality monitoring system; breath checker or fire detection system, MQ2 Gas Sensor Module is very best choice.

What is MQ2 Gas Sensor?

MQ2 is one of the popular and commonly used gas sensors in MQ sensor series. It is a Metal Oxide Semiconductor (MOS) type Gas Sensor also known as Chemiresistors. The detection is based upon change of resistance of the sensing material when the Gas comes in contact with the material. Using a simple voltage divider network, concentrations of gas can be detected.

MQ2 Gas Sensor

MQ2 Gas sensor works on 5V DC and draws around 800mW. MQ2 Gas sensor can detect LPG, Smoke, Alcohol, Propane, Hydrogen, Methane and Carbon Monoxide concentrations anywhere from 200 to 10000ppm.


Here are the complete specifications

Operating voltage5V
Load resistance20 KΩ
Heater resistance33Ω ± 5%
Heating consumption<800mw
Sensing Resistance10 KΩ – 60 KΩ
Concentration Scope200 – 10000ppm
Preheat TimeOver 24 hour

Internal structure of MQ2 Gas Sensor

The sensor is actually close in two layers of fine stainless steel mesh called Anti-explosion network. It verify that heater element inside the sensor will not cause an explosion, as sensor sensing flammable gases.

It also provides protection for the sensor and filters out suspended particles so that only gaseous elements are able to pass inside the chamber. The mesh is bound to rest of the body via a copper plated clamping ring.

This is how the sensor looks like when outer mesh is removed. The star-shaped structure is formed by the sensing element and six connecting legs that extend beyond the Bakelite base. Out of six, two leads (H) are responsible for heating the sensing element and are connected through Nickel-Chromium coil, well known conductive alloy.
The remaining four leads (A & B) responsible for output signals are connected using Platinum Wires. These wires are connected to the body of the sensing element and convey small changes in the current that passes through the sensing element.

The tubular sensing element is made up of Aluminum Oxide (AL2O3) based ceramic and has a coating of Tin Dioxide (SnO2). The Tin Dioxide is the most important material being sensitive towards combustible gases. However, the ceramic substrate merely increases heating efficiency and ensures the sensor area is heated to a working temperature constantly.

So, the Nickel-Chromium coil and Aluminum Oxide based ceramic forms a Heating System; while Platinum wires and coating of Tin Dioxide forms a Sensing System.

How does a gas sensor work?

When tin dioxide (semiconductor particles) is heated in air at high temperature, oxygen is adsorbed on the surface. In clean air, donor electrons in tin dioxide are attracted toward oxygen which is adsorbed on the surface of the sensing material. This prevents electric current flow. In the presence of reducing gases, the surface density of adsorbed oxygen decreases as it reacts with the reducing gases. Electrons are then released into the tin dioxide, allowing current to flow freely through the sensor.

Hardware Overview – MQ2 Gas Sensor Module

Since MQ2 Gas Sensor is not compatible for breadboard. It’s very easy to use and it gives two different outputs. It gives a binary indication of the presence of combustible gases and also provide analog representation of their concentration in air.
When it sense the higher presence of gas it provide higher output voltage, while it sense the lesser presence of gas it provide less output voltage.

Calibrate MQ2 Gas Sensor Module

To set the gas sensor you can hold the gas sensor near smoke/gas you want to detect. Turn the potentiometer until the Red LED on the module starts glowing. If you turn screw clockwise sensitivity increases or anticlockwise to decrease sensitivity.

MQ2 Gas Sensor Module Pinout

The pinout of gas sensor is

VCC supplies power for the module. You can connect it to 5V output from your Arduino.
GND is the Ground Pin and connected to GND pin on the Arduino.
D0 provides a digital output of the presence of combustible gases.
A0 provides analog output voltage in proportional to the concentration of smoke/gas.

Wiring – Connecting MQ2 Gas Sensor Module to Arduino UNO

Now we completely understand how MQ2 Gas sensor works. Let’s hooking it up to our Arduino:
Connection is very simple. Connect VCC pin to 5V of Arduino. Connect GND of MQ2 with GND of Arduino.
Connect D0 pin on the module to Digital pin#8 on Arduino and A0 output pin to Analog pin#0 on the Arduino.
When you complete connection, the circuit looks like

Arduino Code

The code is very simple. It basically reading analog voltage on A0 pin. It also prints a message on serial monitor when smoke is detected. Try the sketch out, before we begin its detailed breakdown.

#define MQ2pin (0)

float sensorValue;  //variable to store sensor value

void setup()
{
  Serial.begin(9600); // sets the serial port to 9600
  Serial.println("Gas sensor warming up!");
  delay(20000); // allow the MQ-6 to warm up
}

void loop()
{
  sensorValue = analogRead(MQ2pin); // read analog input pin 0
  
  Serial.print("Sensor Value: ");
  Serial.print(sensorValue);
  
  if(sensorValue > 300)
  {
    Serial.print(" | Smoke detected!");
  }
  
  Serial.println("");
  delay(2000); // wait 2s for next reading
}

The output on Serial monitor is:

Code Explanation:

First of all we define Arduino pin to which analog pin of MQ2 gas sensor is connected. Create a variable named sensorValue to store sensor value.
#define MQ2pin (0)
float sensorValue; //variable to store sensor value
I void setup function: we initialize serial communications with the Pc.
Serial.begin(9600); // sets the serial port to 9600
Serial.println(“Gas sensor warming up!”);
delay(20000); // allow the MQ-6 to warm up
In loop function: we read sensor value by analogRead() function and store it into the sensorValue variable. Display it on Serial monitor.
sensorValue = analogRead(MQ2pin); // read analog input pin 0
Serial.print(“Sensor Value: “);
Serial.print(sensorValue);
When the gas concentration is very high, the sensor usually outputs value greater than 300. We can monitor this value using if statement. We will display “Smoke Detected” if the sensor value is greater than 300.
if(sensorValue > 300)
{
Serial.print(” | Smoke detected!”);
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Facebook
YouTube
× Contact us