Working with MQ2 Gas Sensor


The MQ-2 Gas Sensor module detects gas leakage in home and industry. The MQ series of gas sensors use a small heater inside with an electrochemical sensor. They are sensitive to a range of gasses and are used indoors at room temperature. The output is an analog signal and can be read with an analog input of the Arduino.


  1. Wide detecting scope
  2. High sensitivity and fast response
  3. Long life and stable
  4. Simple drive circuit


Due to its fast response time and high sensitivity, measurements can be taken as soon as possible. The sensor sensitivity can be adjusted by using the potentiometer.


They are useful in gas leakage detection of LPG, propane, methane, i-butane, alcohol, Hydrogen, and smoke.

Working Principle

The MQ2 has an electrochemical sensor, which changes its resistance for different concentrations of varied gasses. The sensor is connected in series with a variable resistor to form a voltage divider circuit (Fig 1), and the variable resistor is used to change sensitivity. When one of the above gaseous elements comes in contact with the sensor after heating, the sensor’s resistance change. The change in the resistance changes the voltage across the sensor, and this voltage can be read by a microcontroller. The voltage value can be used to find the resistance of the sensor by knowing the reference voltage and the other resistor’s resistance. The sensor has different sensitivity for different types of gasses. The sensitivity characteristic curve (Fig 2) is shown below for the different type of gasses.





1. Ro is the resistance of the sensor in clean air

2. Rs is the resistance of sensor when exposed to gasses

Procedure to Calculate the Concentration of a Particular Type of Gas

To find the concentration of gas, two values has to be measured using a microcontroller with ADC such as Arduino,

1. Ro – The resistance of the sensor when measured in clean air,

2. Rs – The resistance of the sensor when it is exposed to any of the mentioned gasses

To find Ro, connect the sensor to one of the Analog pins of Arduino, note 100 values, and select the median value. This will reduce if any dynamic errors present in the values. The sensor is connected in the series with a variable resistor (Potentiometer on the sensor board). So, to find the resistance of the sensor (Ro or Rs), the resistance of the variable resistor (R1) is required. In most of the MQ2 sensor modules, any one end of the potentiometer and the middle pin of potentiometer will be connected between Sig or Vout Pin and Ground. Find the resistance of R1 using a multimeter and note it down.

The voltage across the sensor Vs (Vs is Vo in Clean Air) is calculated by using the following formula:

Vs=VRef – ADC_Value * (VRefH-VRefL)/(2R)


VRefH is the higher Reference voltage of the ADC, in Arduino, it is usually 5V or 3.3V

VRefL is the lower reference voltage of the ADC, in Arduino, it is usually 0V

R is the resolution of the ADC, in most of the Arduino boards, it is 10 Bits

Once the voltage across the sensor and value of R1 is known, the resistance of the sensor can be calculated by using the formula

Ro=R1 Vo/ (VRef-Vo)

Where Vo is the voltage across the sensor in clean Air

Similarly, the Resistance of the sensor when exposed to gas can be calculated by repeating the above steps and using the formula

Rs=R1 Vs / (VRef-Vs)

Where Vs is the voltage across the sensor in the Air contaminated with LPG molecules

Note: The value of R1 is only for finding the value of Rs and Ro. For finding the concentration of gas, R1 is not required as the concentration is dependent on the Rs/Ro ratio. R1 is not required for finding just the ratio.

Finding the Concentration of a Gas

The concentration of a gas can be calculated by measuring the sensor’s Ro and Rs values and using the following formula

Concentration = Xo (Y/ Yo) Φ

Where Φ is the slope, which can be found using the Sensitivity Characteristic curve and the following formula

Φ = Log (Y2/Y1) / Log(X2/X1)

Where (X2, Y2) and (X1, Y1) are any two points on a section (lines between indicated points on the curve) of the curve. Since the curve has different slopes at different concentrations the (X2, Y2) and (X1, Y1) values should be taken from the corresponding sections

The Xo and Yo values are Initial Concentration and Rs/Ro ratio on a section of the curve (lines between marked points), these values are the starting points of each section (each line between marked points has different slopes)

Y is the Rs/Ro Ratio for the current concentration of the gas

The Arduino code can be found in the below link

To find Ro (Resistance of Sensor in clean air), just run the code in clean air for few minutes (for Accurate values, run it for 24 hours) and note down the resistance in the serial monitor.


About Mehter Muzzamil

Mehter Muzzamil is a software developer at Vmoksha Technologies who is having knowledge in the android domain and Internet of Things. He is passionate about exploring emerging technologies like Internet of Things and loves the varieties of challenges that these technologies bring. Apart from this, he likes to spend his time in reading books, watching movies, and playing games.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>