The MQ-2 gas sensor has high sensitivity to LPG, Propane and Hydrogen, also could be used to detect Methane, it is low cost and suitable for several different applications.
Characteristics
* Good sensitivity to Combustible gas in wide range
* High sensitivity to LPG, Propane and Hydrogen
* Long life and low cost
* Simple drive circuit
Application
* Domestic gas leakage detector
* Industrial Combustible gas detector
* Portable gas detector
The sensitivity of the sensor can be adjusted by using the potentiometer that is fitted to the module pictured above. As this is an Analog output sensor this sensor needs to be connected to one of the available Arduino Analog inputs. We are going to use the A0 analog pin in our example below
TheĀ Gas sensor that we bought is named as below, some may have 3 pins and omit the DOUT pin which is not used
Arduino | Gas Sensor |
---|---|
5V | VCC |
GND | GND |
N.C | DOUT |
Analog A0 | AOUT |
Code
A basic example here, you would probably want to do sampling of several readings and take the average. Watch the following
sensorVoltage = sensorValue/1024*5.0;
The 5.0 is the voltage (Vcc), this is very unlikely to be exactly 5.0 v so for extra accuracy you may to measure that with a multi-metre first
[codesyntax lang=”cpp”]
void setup() { Serial.begin(9600); } void loop() { float sensorVoltage; float sensorValue; sensorValue = analogRead(A0); sensorVoltage = sensorValue/1024*5.0; Serial.print("sensor voltage = "); Serial.print(sensorVoltage); Serial.println(" V"); delay(1000); }
[/codesyntax]
Results
Open the serial monitor and you should something like this
Links
MQ-2 sensor spec
MQ-2 Gas Sensor Module LPG, propane, hydrogen detection