Categories
TUTORIALS

Using the MQ-2 Sensor for Smoke Level Detection

Introduction

The MQ2 sensor is a commonly used gas sensor that can detect a variety of gases such as propane, methane, and carbon monoxide, as well as smoke. It works by measuring the change in resistance of its sensitive material when it comes into contact with the gas or smoke. This makes it a valuable tool for monitoring air quality in various applications such as indoor air quality control, gas leakage detection, and fire prevention.

As part of a larger prototype to detect high pollution levels for Philadelphia’s playgrounds, this tutorial shows you how to build a sensor circuit and set a threshold for smoke detection that lights up a LED. In this demo, we are measuring smoke concentration.

Background Information

As part of this kit available on Amazon, the MQ2 sensor is a device that can detect different gases and smoke in the air. It is composed of a ceramic substrate with a tin dioxide sensitive layer that changes its resistance when exposed to gas or smoke. The sensor’s response time and sensitivity are improved by heating the SnO2 layer. When it detects a gas or smoke, it sends a signal to the computer that can be read on the serial monitor (if you are using Arduino’s IDE). The stronger the gas or smoke, the stronger the signal. The application of this sensor is mostly to detect gas leaks or indoor fire.

The MQ2 Sensor and its parts. Source: Buy MQ2 Gas Sensor Module for LPG/Smoke Detection – QuartzComponents
Basic concept of MQ2 Sensor. Source: Guide for MQ-2 Gas Sensor with Arduino | Random Nerd Tutorials
Internal Schematic Diagram for MQ2 Sensor. Source: Arduino MQ-2 Gas Sensor Tutorial – How Does a Gas Sensor Work and How to Interface it with Arduino? (circuitdigest.com)

The MQ2 sensor is capable of detecting a range of gases, including:

  1. LPG (liquefied petroleum gas)
  2. Propane
  3. Methane
  4. Butane
  5. Alcohol
  6. Hydrogen
  7. Smoke
  8. Carbon monoxide (CO)

The sensitivity of the sensor to each gas may vary, and the sensor can be calibrated for specific gases to improve its accuracy.

The MQ2 sensor has several basic uses, including:

  1. Gas leak detection: The MQ2 sensor can detect the presence of flammable gases such as propane, butane, and methane, making it useful for gas leak detection in homes, offices, and industrial settings.
  2. Smoke detection: The MQ2 sensor can also detect smoke, making it useful for fire detection and prevention in homes and buildings.
  3. Air quality monitoring: The MQ2 sensor can detect gases such as carbon monoxide (CO) and alcohol, which are harmful to human health in high concentrations. This makes it useful for indoor air quality monitoring and control.
  4. Environmental monitoring: The MQ2 sensor can also be used for environmental monitoring of gas emissions from factories, vehicles, and other sources.

Wiring Diagram

Wiring Diagram made on Circuit.io. Note: The pins do not match, refer to images and table below and code for exact match.
A picture of the circuit

List of Parts & Assembly

  1. Methane, Butane, LPG and Smoke Gas Sensor – MQ-2 (Link)

2. ELEGOO UNO R3 Board ATmega328P with USB Cable(Arduino-Compatible) for Arduino and USB cable (Link)

3. BreadBoard – Half Size or Full Size (Link)

4. LED – Basic Red 5mm (Link)

5. 220 Ohm Resistor (Link)

6. Jumper Wires Pack – M/M (Link)

Refer to this table for correct pins when using the code from this tutorial.

  1. Using a bread board, put the red LED onto it, and connect the positive pin to the digital pin 6 on the Arduino Uno board, and the negative pin to ground. The negative pin should be connected to a resistor as shown in the diagram and picture.
  2. The MQ2’s Analog output should be connected to A0 on the Arduino Uno board using a Male to Female jumper wire. The VCC should be connected to 5V, and ‘Gnd’ to ground on the Arduino Uno board.

Arduino Code

The Arduino code for this tutorial was built on code from “How Does MQ-2 Flammable Gas and Smoke Sensor Work with Arduino?” and “How MQ2 Gas/Smoke Sensor Works? & Interface it with Arduino“.

The threshold of ‘100’ was used for demonstration purposes and can be based on further research. The detection range for the sensor depends on the gas, and for smoke it depends on various factors. Generally, over 400 is considered dangerous, but this value can be calibrated based on the environment.

Note: These units are in ‘ppm’ or parts per million. In the context of the MQ2 sensor, ppm refers to the number of gas molecules per million air molecules. For example, if the MQ2 sensor detects 100 ppm of propane, it means that for every one million air molecules, there are 100 propane molecules.

Serial Monitor Readings

The following image shows readings in a normal state, when there isn’t any smoke. The LED is switched off at this point.

The following image shows readings when smoke is around the sensor. The ‘smoke detected’ test is a warning added for when the smoke crosses the 100 level.

Demo Video

In the demo, using the code above, I let the sensor warm up for about 10 minutes. I had used the sensor previously, so the warm up time was lower. When using for the first time, let it warm up for 30 min. Once the readings started appearing on the serial monitor, I waited for them to gradually decrease (since this is how the sensor works: it starts with high readings). I used a candle and burnt some paper in the candle’s jar to create smoke and let the sensor hover around it. At this point, the LED turns on, and the serial monitor shows ‘Smoke Detected’ with the smoke levels >100. I move the sensor back to the original position and out of the jar’s way; the LED then switches off.

References

Datasheet: Microsoft Word – MQ-2 new.doc (pololu.com)

How Does MQ-2 Flammable Gas and Smoke Sensor Work with Arduino?

How MQ2 Gas/Smoke Sensor Works? & Interface it with Arduino

Guide for MQ-2 Gas/Smoke Sensor with Arduino

Leave a Reply

Your email address will not be published. Required fields are marked *