Smoke detector using MQ-2 sensor and Arduino

What is MQ-2 smoke detector?

The MQ-2 smoke sensor is sensitive to smoke other inflammable gases like LPG, Butane, Propane, Methane, Alcohol, Hydrogen

The resistance of the sensor is different depending on the type of the gas.
The smoke sensor has a built-in potentiometer that allows you to adjust the sensor sensitivity according to how accurate you want to detect gas.

MQ-2 Sensor

The output can be an analog signal (A0) that can be read with an analog input of the Arduino or a digital output (D0) that can be read with a digital input of the Arduino

Parts required

To make smoke detector using MQ-2 we need following parts:

  1. Arduino UNO
  2. MQ-2 sensor
  3. LED -2 ( 1 Red and 1 Green)
  4. Buzzer


Pin Wiring

The MQ-2 sensor and LED pins need to be connected as per the table below:

MQ-2 Pin A0————————– Arduino Pin A5

MQ-2 Pin D0————————–Arduino Digital pin (we will not use digital pin)

MQ-2 Pin GND ———————–Arduino GND pin

MQ-2 Pin VCC ————————Arduino Pin VCC

LED Red ——————————- Arduino Pin 12

LED Green —————————- Arduino Pin 11

Buzzer ———————————Arduino Pin10





int redLed = 12;
int greenLed = 11;
int buzzer = 10;
int smokeA0 = A5;
// Your threshold value
int sensorThres = 400;

void setup() {
  pinMode(redLed, OUTPUT);
  pinMode(greenLed, OUTPUT);
  pinMode(buzzer, OUTPUT);
  pinMode(smokeA0, INPUT);

void loop() {
  int analogSensor = analogRead(smokeA0);

  Serial.print("Pin A0: ");
  // Checks if it has reached the threshold value
  if (analogSensor > sensorThres)  
    digitalWrite(redLed, HIGH);
    digitalWrite(greenLed, LOW);
    tone(buzzer, 1000, 200);
    digitalWrite(redLed, LOW);
    digitalWrite(greenLed, HIGH);

Completed Project


Following is the Youtube video


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.