How to Use MQ2 Gas Sensor - Arduino Tutorial

256,268

253

56

Introduction: How to Use MQ2 Gas Sensor - Arduino Tutorial

About: Arduino Tutorials by Codebender.cc 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!

Recommendations

  • Science Fair Challenge

    Science Fair Challenge
  • Home and Garden Contest

    Home and Garden Contest
  • Electronics Contest

    Electronics Contest

56 Comments

0
nivekkan
nivekkan

6 months ago

Bro u saved my assignment. thanks

0
SujanD1
SujanD1

6 years ago

do we have to heat the sensor externally for some time before taking reading???

0
technoelectronics44
technoelectronics44

Reply 1 year ago

if it is normal temperature no problem, if you increase the temperature beyond the limits it is getting damage

0
fizahsarkawi93
fizahsarkawi93

6 years ago

can i have the schematic sketch pls ?

0
technoelectronics44
technoelectronics44

Reply 1 year ago

you can find in Technoelectronics44

0
BallscrewBob
BallscrewBob

6 years ago

What about the fourth pin ?

0
technoelectronics44
technoelectronics44

Reply 1 year ago

it has VCC,GND,D0,A0 pins.
in this article A0 pin is interface with analog pin of microconteroller , if you want to interface with digital pin of microcontroller then you can use D0 pin of sensor

0
pfeerick
pfeerick

Reply 6 years ago

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.

0
TarekS30
TarekS30

5 years ago

Can i supply this sensor with a 9V battery?

0
Mickey The Maker
Mickey The Maker

Reply 2 years ago

You can supply the adrinio with a 9V battery.

0
nishanthgadam
nishanthgadam

2 years ago

Thanks for sharing this article nice info
gas transmitters

0
HanNaKim02
HanNaKim02

Question 3 years ago

does we need to combine the lcd coding with this MQ-2 coding to get the value of smoke? or it just appear on lcd when we set it up on the breadboard?

0
Ankitp1995
Ankitp1995

Question 3 years ago on Step 4

i have MQ2 and MQ 4 sensor and arduino uno, i want to check methane composition in biogas. i want codes please help me

0
LukasS8
LukasS8

6 years ago on Introduction

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

0
codebender_cc
codebender_cc

Reply 6 years ago on Introduction

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

0
JAK101
JAK101

Reply 6 years ago

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.

0
ChoudharyA2
ChoudharyA2

Reply 4 years ago

Noise Issue?? Can you explain

0
TheMake
TheMake

Reply 6 years ago

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