loading

The MQ series of gas sensors use a small heater inside with an electro-chemical sensor. They are sensitive for 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.

The MQ-2 Gas Sensor module is useful for gas leakage detecting in home and industry. It can detect LPG, i-butane, propane, methane ,alcohol, hydrogen and smoke.

Some modules have a built-in variable resistor to adjust the sensitivity of the sensor.

Note: The sensor becomes very hot after a while, don't touch it!

In this tutorial we will use the serial monitor of Codebender (or Arduino IDE) to see how the sensor acts in variable gasses.

So, let's get started!

Step 1: What You Will Need

For this tutorial you will need:

  • Arduino uno
  • Breadboard
  • MQ-2 Gas sensor module

<p>How to use MQ2 sensor as alcohol detector?please give me tutorial</p>
<p>hi. Can I use arduino nano. Please help me.</p>
<p>yes can</p>
<p>thanks</p>
<p>my pleasure</p>
<p>the nano just has another footprint but the pins the same</p>
<p>Hi there,</p><p>I am new to this gas sensors. Wants a clarity.</p><p>the output that is showing serial monitor is</p><p>151</p><p>152</p><p>151</p><p>and so on..</p><p>Are they ppm or concentration of the gas.</p>
<p>I replied above on another comment on how you would make sense of the numbers. They are not PPM but an analog voltage that relates to the range of detectable values. More details in my other comment.</p>
<p>I connected my MQ2 gas sensor (http://www.seeedstudio.com/wiki/Grove_-_Gas_Sensor(MQ2))and got results as follows</p><p>79 </p><p>100</p><p><br>67</p><p><br>85</p><p><br>35</p><p><br>...How do i interpret them</p><p>Whats should be the position of resistor pot? here its pointing at &quot;1&quot;</p>
<p>The arduino is reporting analog voltage levels, represented by numbers ranging from 0 (0 VDC) to 1023 (5 VDC) in increments of 0.0049 VDC. (https://www.arduino.cc/en/Reference/analogRead)</p><p>If you want to get PPM, you will need to remap values from 0-1023 to the appropriate ppm. According to the datasheet for the MQ2, it is sensitive to 300-10000 PPM. A rough approximation would be the analog read value (79, 100, 67, ...) * (10000-300)/1024. Or, approximately analog read value * 9.5. So given the values you reported, the estimated PPM of combustible gases is between 330 and 950 PPM.</p><p>The Lower Explosive Limit (LEL) of propane for example is 2.1%, or 21000 PPM, so you are well below that threshold. However, the permissible exposure level is 1000 PPM, so I am almost certain that your potentiometer needs to be adjusted. How much is impossible to say.</p><p>To calibrate, you would need to enclose the sensor in some sort of chamber, and then introduce a known concentration of a gas into the chamber (dangerous if you don't know what you are doing). The safer method is to compare readings with a known working meter, which provides a ppm readout (expensive).</p><p>Bear in mind, that without calibration, these values may be off. These are cheap sensors, so quality control is questionable. You should not rely on this for actual life safety. You should also be aware that the MQ2 is sensitive to several gases, so while propane has an LEL of 2.1%, methane has an LEL of 5%. </p>
<p>Hey, I'm getting the same values. Is there a way to interpret them at all?</p>
How to set program <br>When sensore active blink red light (13 to GND )LED
<p>Hi there, thanks for this. I got a new edison and some MQ sensors. I tried this code and it is now giving me some data ranging from 90s to 200.</p><p>I want to be able to measure various pollutants like CO2, CO, LPG, Smoke etc present indoors using these sensors and my edison board.</p><p>What are next steps? Could you please advise?</p>
<p>You might want to update the article soon as codebender is closing down...</p><p>You could try the Arduino CREATE as that lets you share code too</p>
<p>so does this code applies to MQ-138. I'm having trouble with this sensor. They pretty do look like the same with 4 pins</p>
<p>it is very interesting</p>
<p>Arduino is fun..</p>
<p>Hey Everyone, </p><p>I am Using MQ-2 gas sensor with four pins and a raspberry pi. I have tried several codes and connection options. Could anyone help me with materials and python code, please? Here is my e-mail: johnogbonoko@gmail.com</p>
<p>Hey Everyone, </p><p>I am Using MQ-2 gas sensor with four pins and a raspberry pi. I have tried several codes and connection options. Could anyone help me with materials and python code, please? Here is my e-mail: johnogbonoko@gmail.com</p>
<p>i want a circuit diagram for connection....</p>
<p>I guess that:<br></p><ul><br><li>Vcc to Arduino 5V pin<li>GNG to Arduino GND pin<li>Output to Arduino Analog A0 pin<br></ul><p>really shouldnt be so hard to understand that you can't draw a circuit diagram for yourself if you need one</p>
<p>diy_bloke gave a good explanation, as I have made a similar project you can take a look at</p><p><a href="https://www.instructables.com/id/Precise-Air-Quality-Monitoring-System/" rel="nofollow">https://www.instructables.com/id/Precise-Air-Qualit...</a></p><p>If you like this project then </p><p>Do vote for it !! :) </p><p>Thank you !!</p>
<p>can i have the schematic sketch pls ? </p>
<p>do we have to heat the sensor externally for some time before taking reading???</p>
<p>Hey could one arduino power all MQ Sensors (MQ-2,3,4,5,6,7..) or would it need to much current?</p>
<p>I don't know... maybe you will need an external power source. </p>
<p>You can only use an external power source to power the digital IO pins. External power for analog is not recommended due to noise issues.</p>
<p>maybe you could us a voltage regulator or same what you said...... :)</p>
<p>Your best bet is to buy a sensor shield and use it with your Uno or Mega (I prefer the mega because there are more IO pins). However, you should note that no matter which board you choose it can only supply so much current to each sensor. You reach a point where you run out. Adding an external power supply doesn't work either with the sensor shields. External power isn't applied to the analog pins due to noise issues. Basically, you are limited on the amounts of analog sensors you can use.</p>
<p>it could power any of these with 5v</p>
<p>it could power any of these with 5v</p>
<p>Hi </p><p>I am using sensor from http://www.seeedstudio.com/wiki/Grove_-_Gas_Sensor(MQ2)</p><p>I get random values while I place the sensor in various positions...How do I fix them.</p><p>How do I program it such that it can sensor various gases??</p><p>Pls help....</p>
<p>How to get the composition of gases detected by the sensor?</p><p>This code above will only give a 10bit A2D converted value which is of no use until the % or any amount of gases is not known.</p><p>Please elaborate....i am looking for this for a while!</p><p>Thanks</p>
<p>Arduino: 1.6.6 Hourly Build 2015/09/09 11:42 (Windows 8.1), Board: &quot;Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)&quot;</p><p>Sketch uses 2,646 bytes (1%) of program storage space. Maximum is 253,952 bytes.<br>Global variables use 200 bytes (2%) of dynamic memory, leaving 7,992 bytes for local variables. Maximum is 8,192 bytes.<br>avrdude: ser_open(): can't open device &quot;\\.\COM1&quot;: The system cannot find the file specified.</p><p><br>avrdude: ser_drain(): read error: The handle is invalid.</p><p><br>Problem uploading to board. See <a href="http://www.arduino.cc/en/Guide/Troubleshooting#upload" rel="nofollow">http://www.arduino.cc/en/Guide/Troubleshooting#upload</a> for suggestions.</p><p> This report would have more information with<br> &quot;Show verbose output during compilation&quot;<br> enabled in File &gt; Preferences.</p>
<p>I know this comment is a little old now but the problem is more likely to be with the IDE you are using. Just posting this to let others know that there have been and apparently still are issues with most of the newer IDE's from 1.6.6 upward. More so if you use ESP boards too. Check the Arduino forums on a regular basis to see which are the most stable. Lots of people went back to 1.6.5 but only after a major clean up of prev installs.</p>
<p>Install drivers and plugin of Codebender, select com port and your Arduino board and then press the green button &quot;Run on Arduino&quot;.</p>
How to us eit with a buzzer
<p>What about the fourth pin ?</p>
<p>The forth pin (the unused one in this project) will be the digital/TTL pin, that will either be high (1) or low (0), and the trigger point is set using the potentiometer on the other side. Useful when you want to simply trigger when a set amount of gas is present.</p>
<p>I like the project</p>
<p>thank u</p>
great<br>
<p>Great tutorial. Thanks for sharing!</p>
Thanks! I've been wanting to get one of these....<br>I had an idea that would make a great gift for my buddy's wife. He's got this talent for creating rather potent digestion byproducts, often without auditory warning . An MQ and uC embedded between vehicle seat bottom and back could be used to trigger a relay to automatically drop the power windows.
<p>qtechnow has a methane (fart) module for sale using the MQ-4 sensor. I'm hoping to use it for a robot in a daycare centre that response when it gets close to the diaper change table. http://www.qtechknow.com/products/9203</p>
<p>Yes, Thanks!.... I have been looking for a tutorial about these inexpensive gas sensors...</p>

About This Instructable

144,990views

227favorites

License:

Bio: Arduino Tutorials by Codebender.cc Team
More by codebender_cc:How to use a magnetic door switch / sensor with Arduino How to Measure LUX With Arduino How to Control an RGB LED Strip - Arduino Tutorial 
Add instructable to: