Home ArduinoArduino Code Arduino MQ-2 Gas Sensor example

Arduino MQ-2 Gas Sensor example

by iainhendry71

The MQ-2 is a fairly low cost sensor that can detect  LPG, i-butane, propane, methane ,alcohol, Hydrogen, smoke. There are a wide variety of shields and modules that can be bought and connected to your Arduino

You can see the sensor in the image below

VCC – 5V
AOUT – Analog pin 0

gas sensor

gas sensor




const int analogInPin = 0;
int sensorValue = 0;
int count1;
void setup() 
void loop() 
  // read the analog in value:
  sensorValue = analogRead(analogInPin);            
   Serial.println(sensorValue, DEC);  // prints the value read

When this run, open up the serial monitor and you should see something like the following

mq2 output

mq2 output


You can pick up one of these modules from between $3 to $5

KEYES DIY 3 pin MQ2 Smoke Gas Sensor Module for Arduino with Connection Cable Red

SainSmart MQ2 Gas Sensor Module For LPG Propane Hydrogen Arduino Compatible

You may also like