Interfacing MQ-2 Smoke Gas Sensor with Arduino


In this tutorial, we will learn how to Interfacing MQ-2 Smoke Gas Sensor with Arduino, MQ-2 smoke sensor is a gas sensor that can detect a variety of gases such as smoke, methane, propane, butane, and liquefied petroleum gas (LPG). It is widely used in smoke alarms, gas leakage detectors, and other applications to monitor air quality.

MQ-2 smoke sensor is an affordable and effective solution to detect smoke and a variety of flammable gases. It is widely used in various applications due to its high sensitivity, low cost, and long lifespan. By using an Arduino, we can easily process the output of the sensor and create a smoke alarm or gas leakage detector system.

Hardware Required

You will require the following Hardware Components for Interfacing MQ-2 Smoke Gas Sensor with Arduino.

Components#Buy From Amazon
Arduino UNO1Buy Now
MQ-2 Sensor Module1Buy Now
LED 5mm1Buy Now
Resistors 220Ω1Buy Now
Jumper WiresBuy Now
Breadboard1Buy Now

What is MQ-2 Smoke Sensor?

The MQ2 gas sensor is a module that can detect various types of gases, such as smoke, propane, methane, butane, alcohol, and carbon monoxide. It is based on the principle of sensing different gases through their interaction with the sensor’s surface. The MQ2 gas sensor consists of a small heating element and a sensing element made of a metal oxide semiconductor material. When the sensing element is exposed to a gas, its resistance changes and this change is proportional to the concentration of the gas in the surrounding environment. The sensor can be connected to a microcontroller, such as an Arduino board, to measure and monitor the concentration of gases in the environment. It is commonly used in gas leakage detection, fire detection, and air quality monitoring applications.


  • Operating Voltage: 5V DC
  • Operating Current: < 150 mA
  • Detection Range: 300 – 10000 ppm
  • Heater Resistance: 31Ω ± 3Ω
  • Sensing Resistance: 1KΩ – 20KΩ in 1000 ppm propane
  • Sensitivity: R in air/R in gas ≥ 5
Operating voltage5V
Load resistance20 KΩ
Heater resistance33Ω ± 5%
Heating consumption<800mw
Sensing Resistance10 KΩ – 60 KΩ
Concentration Range200 – 10000ppm
Preheat TimeOver 24 hour


  1. High sensitivity to smoke and a variety of flammable gases
  2. Low cost and easy to use
  3. Analog and digital outputs
  4. Adjustable sensitivity through a potentiometer
  5. Stable and long lifespan



Pin Configuration

Pin NamePin Type
VCCPositive supply Pin
GNDGround Pin
A0Analog Pin
D0Digital Pin

Working Explanation

The MQ-2 smoke sensor works on the principle of gas sensing. It has a small heater coil that heats the sensing element, which is made up of a metal oxide semiconductor material. When the target gas comes in contact with the sensing element, the resistance of the element changes, and this change in resistance is measured by the circuit. The output of the sensor is an analog signal that can be processed by an Arduino to detect the presence of smoke or other gases.

Circuit Diagram

The following circuit shows you the connection of the MQ-2 Smoke Sensor with Arduino Please make the connection carefully


Circuit Connections

Connect the MQ-2 smoke sensor to the Arduino by connecting the following pins:
VCC to 5V on the Arduino
GND to GND on the Arduino
A0 to an analog input pin on the Arduino (e.g. A0)
And the D0 does not connect with Arduino

ArduinoMQ-2 Module

Installing Arduino IDE Software

First, you will require to Download the updated version of Arduino IDE Software and Install it on your PC or laptop. if you Learn How to install the Arduino step-by-step guide then click on how to install Arduino Button given Blow


The Giver Below sketch determines whether the gas concentration is within proper limits.

//For more Projects:

#define ledPin 6

#define sensorPin A0

void setup() {


  pinMode(ledPin, OUTPUT);

  digitalWrite(ledPin, LOW);

void loop() {

  Serial.print("Analog output: ");



//  This function returns the analog data to calling function

int readSensor() {

  unsigned int sensorValue = analogRead(sensorPin);  // Read the analog value from sensor

  unsigned int outputValue = map(sensorValue, 0, 1023, 0, 255); // map the 10-bit data to 8-bit data

  if (outputValue > 65)

    analogWrite(ledPin, outputValue); // generate PWM signal


    digitalWrite(ledPin, LOW);

  return outputValue;             // Return analog moisture value



  1. Smoke alarms and detectors
  2. Gas leakage detectors
  3. Air quality monitoring
  4. Industrial safety systems
  5. Environmental monitoring

See Also

  1. Interface MS5611 Barometric Pressure Sensor with Arduino Tutorial
  2. FollowMe – Simple Game using Arduino
  3. Simple Buzz Wire Game using Arduino

Leave a Comment