Introduction: How to Detect Concentration of Gas by Using MQ2 Sensor

Picture of How to Detect Concentration of Gas by Using MQ2 Sensor

MQ-2 Gas sensor is used to detect the gas level around the area. This sensor able to use as home or factory gas leak monitoring, suitable for gas, butane, propane, methane, alcohol, hydrogen, smoke and other monitoring devices.

Specification:

  • Size: 35mm x 22mm x 23mm (length x width x height)
  • Main chip: LM393, ZYMQ-2 gas sensors
  • Working voltage: DC 5 V
  • Characteristics:
  1. With a signal output instruction.
  2. Dual signal output (analog output, and high/low digital output)
  3. 0 ~ 4.2V analog output voltage, the higher the concentration the higher the voltage.
  4. Better sensitivity for gas, natural gas, city gas.
  5. With a long service life and reliable stability.
  6. Rapid response and recovery characteristics.

Step 1: Gather Materials

Picture of Gather Materials

Step 2: Understanding Pin Definition of MQ2 Gas Sensor

Picture of Understanding Pin Definition of MQ2 Gas Sensor

Step 3: Set Up the Circuit Above

Picture of Set Up the Circuit Above

LCD pins

-Pins D7 , D6 , D5 , D4 connect to arduino digital pins 2,3,4,5 respectively.

-Pins A and K connect to 5V and GROUND respectively

-Pins VSS and VDD connect to Ground and 5V respectively.

LED

-Use as a LED indicator for the calibration process of the MQ2 gas sensor

-Connect to digital pin 13 of Arduino Uno

MQ2 Gas Sensor

-Analog output connect to the A0 of arduino

Potentiometer

-Center pin connect to the V0 of LCD display

-Other two pins just connect to 5V and GROUND respectively

*Note: All of pins above is configured regarding the circuit figure above. You can configure the connection yourself regarding your favourite.

Step 4: Programming the Arduino Uno

Picture of Programming the Arduino Uno

As you can see in the graph above , it shows several gases.

The values are plotted on a semilog paper, as you can see the values indicate 100......1000.....10000 ppm.

These values when plotted on a normal graph would represent a curve like an exponential one.

Formula In the Coding

pow(10,( ((log(rs_ro_ratio)-pcurve[1])/pcurve[2]) + pcurve[0]))

Based on the graph MQ2, the derivation of ppm formula will be:

Y - y1 = m( X - x1)

X= (y-y1)/m + x1

X= (Rs/Ro-y1)/m + x1

log X =(log (Rs/Ro) - y1)/m +x1

X =10^( (log (Rs/Ro) - y1)/m +x1)

*Note: X = ppm on the graph

Y= Rs/Ro

***The derivation formula are same and can be used for other types of MQ gas sensor.

If you have any problem about the coding, you are welcome to ask any question in the comments below or contact us for further details.

Comments

riker65 (author)2017-11-16

Hi how do you distinguish the different gases? this is not clear to me

srisha_robotics (author)2017-09-03

HI . from the graph how to find x y and slope .. pls help me out

nazaninazad (author)2017-07-22

hi . please give us an example about how i can detect a gas with mq2 ireallyneed to underestand this because of my project i really need an example....please help me

GustavoFernandes (author)2016-10-22

hi , how do I detect hydrogen ????????????????

hi did you get your answer ???

nazaninazad (author)2017-07-22

hi . please give us an example about how i can detect a gas with mq2 sensor i really need to underestand this because of my project i really need an example....please help me

AIS9 (author)2017-06-14

If i may ask, how did you get these values LPGCurve[3] = {2.3,0.21,-0.47}; //two points are taken from the curve.

DavidS1188 (author)2017-01-23

Hi! I am trying to integrate your sketch into a room climate station where I also run a DHT22 and a Shinyei PPD42 to measure temperature, air humidity and dust.

When compiling the sketch I always get the error message that MQCalibration was not declared (line 56 in your sketch)

Since my setup is quite different I can not run your sketch without rebuilding the whole thing...

AbdAbed01 (author)2017-01-14

How does smoke concentration measured and sensed by the MQ-2 brief please??

DhayanieM (author)2016-09-08

can we use the same coding and fixing for MQ7

TheThinker (author)2016-07-05

What's the power consumption of the gas sensor module?

mybotic (author)TheThinker2016-07-11

Hi, we are not sure for it. Anyway you may refer to the datasheet
https://drive.google.com/file/d/0B8OvrwVDp8fCdDV3eDN3YXpsVzg/view

About This Instructable

7,941views

10favorites

License:

More by mybotic:Tutorial for ESP8266 ESPDuino NodeMcu SPI Module Using Arduino UnoTutorial for L298 2Amp Motor Driver Shield for ArduinoTutorial for VNH2SP30 Monster Motor Module (Single Channel)
Add instructable to: