How to Use MQ2 Gas Sensor - Arduino Tutorial





Introduction: How to Use MQ2 Gas Sensor - Arduino Tutorial

About: Arduino Tutorials by Team

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

Step 2: The Circuit

The connections are pretty easy:

  • Vcc to Arduino 5V pin
  • GNG to Arduino GND pin
  • Output to Arduino Analog A0 pin

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

Step 3: The Code

Here's the code, embedded using Codebender!

Try downloading the codebender plugin and clicking on the Run on Arduino button to program your Arduino with this sketch. And that's it, you've programmed your Arduino board! Press connect button to start serial communication with your Arduino board.

Now you can try this:

Take a lighter and press the button to release gas near the sensor. Observe values on serial monitor.

You can keep playing with that by clicking the "Edit" button and start making your own modifications to the code.

Step 4: Well Done!

You have successfully completed one more Arduino "How to" tutorial and you learned how to use the MQ-2 Gas sensor with Arduino.

Tip: You can use this tutorial to read values from all MQ gas sensors (MQ-2, MQ-3, MQ-4, MQ-5, MQ-6, MQ-7, etc)

I hope you liked this, let me know in the comments.
There will be more of them, so make sure to click Follow button!

6 People Made This Project!


  • Woodworking Contest

    Woodworking Contest
  • Casting Contest

    Casting Contest
  • Clocks Contest

    Clocks Contest

We have a be nice policy.
Please be positive and constructive.




Hey could one arduino power all MQ Sensors (MQ-2,3,4,5,6,7..) or would it need to much current?

7 replies

I don't know... maybe you will need an external power source.

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.

Noise Issue?? Can you explain

maybe you could us a voltage regulator or same what you said...... :)

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.

it could power any of these with 5v

it could power any of these with 5v

Thanks very much, I've enjoy a lot making it.

From Madrid, Spain

Can i supply this sensor with a 9V battery?

How to use MQ2 sensor as alcohol detector?please give me tutorial

the nano just has another footprint but the pins the same

Hi there,

I am new to this gas sensors. Wants a clarity.

the output that is showing serial monitor is




and so on..

Are they ppm or concentration of the gas.

1 reply

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.

I connected my MQ2 gas sensor ( got results as follows






...How do i interpret them

Whats should be the position of resistor pot? here its pointing at "1"

1 reply

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. (

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.

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.

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).

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%.