Arduino MQ-2 gas sensor example


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.

MQ-2 gas sensor
MQ-2 gas sensor


* Good sensitivity to Combustible gas in wide range
* High sensitivity to LPG, Propane and Hydrogen
* Long life and low cost
* Simple drive circuit


* 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

ArduinoGas Sensor
Analog A0AOUT


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

void setup()
void loop()
  float sensorVoltage;
  float sensorValue;
  sensorValue = analogRead(A0);
  sensorVoltage = sensorValue/1024*5.0;
  Serial.print("sensor voltage = ");
  Serial.println(" V");



Open the serial monitor and you should something like this



MQ-2 sensor spec
MQ-2 Gas Sensor Module LPG, propane, hydrogen detection

You might also like More from author

Comments are closed, but trackbacks and pingbacks are open.