Ardumotive Arduino Greek Playground
  • Home
    • Blog
    • About us
    • Contact
    • License
  • Events
    • Unboxing & Review
  • Tutorials
  • Workshop
  • RPi Tutorials
  • News
The 1st Arduino Playgroung in Greece - Open Source Hardware

Gas Sensor

Available Languages
Greek
English

Introduction 

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

What you will need - Hardware

For this project you will need:
  • Arduino uno
  • Breadboard
  • MQ-2 Gas sensor module (board, MQ2)
  • 4.7K Resistor
Picture

The Circuit

The connections are pretty easy, see the image above with the breadboard circuit schematic.
  • Vcc & GND pins of sensor --> Arduino GND
  • Signal (middle pin) --> Arduino Pin 2
  • 4.7K Resistor between signal pin and 5V pin

The code using Codebender

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
/* Testing MQ-2 GAS sensor with serial monitor
   Suitable for detecting of LPG, i-butane, propane, methane ,alcohol, Hydrogen or smoke
   More info: http://www.ardumotive.com/how-to-use-mq2-gas-sensor-en.html
   Dev: Michalis Vasilakis // Date: 11/6/2015 // www.ardumotive.com                     */

const int gasPin = A0; //GAS sensor output pin to Arduino analog A0 pin


void setup()
{
	Serial.begin(9600); //Initialize serial port - 9600 bps
}

void loop()
{
	Serial.println(analogRead(gasPin));
	delay(1000); // Print value every 1 sec.
}
mq2gas_tutorial.zip
File Size: 0 kb
File Type: zip
Download File

Download the code from here and open it with Arduino IDE. Open the serial monitor from tools menu of Arduino IDE.
​
Now you can try this:
Take a lighter and press the button to release gas near the sensor. Observe values on serial monitor.

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

Search Engine

Licence 

Picture

Help us to grow up!

Picture


Donate us
About us
License
Cookies policy

Visit the biggest Arduino Shop in Greece!

Picture
find us on dwrean.net
find us on Codebender
find us on Instructables
Developed and designed by Vasilakis Michalis Copyright © 2013 Ardumotive All Rights Reserved
All trademarks referenced herein are properties of their
Powered by Create your own unique website with customizable templates.
Design by DivTag Templates