0

members

Easy Basics: Project 029a Gas Sensor MQ-2, LEDs, active piezo buzzer - Flammable Gas Detection

of Lex C in UNO

Basics: Project 029a

Project name: Gas Sensor MQ-2, LEDs, active piezo buzzer - Flammable Gas Detection

Attachments: sketch1

In this project, you needed these parts :

1.Aruduino Uno R3 (you can also use the other version of Arduino)

2.Arduino IDE ( you can download it from here  )

3.Jumper cables

4. Breadboard

5. Gas Sensor MQ-2 1 pc

 

6. LED 2 pcs (red and green color)

7. Resistor 2 pcs (220 Ohm each)

8. Active pize buzzer 1 pc

General

We will learn how to connect Gas Sensor MQ-2, active piezo buzzer and LEDs to Arduino board.

Understanding the piezo buzzer

You can read more about it here.

Understanding the Gas Sensor MQ-2

Gas Sensor MQ-2 is a sensor for flammable gas and smoke by detecting the concentration of combustible gas in the air. They are often used in gas detecting equipment for smoke and flammable gasses such as LPG, i-butane, propane, methane, hytrogen and alcohol in household, industry or automobile.The MQ-2 smoke sensor is sensitive to smoke and to the following flammable gases:

MQ-2 gas sensor applies SnO2 (an oxygen-deficient n-type semiconductor) which has a lower conductivity in the clear air as a gas-sensing material. In an atmosphere where there may be inflammable gases, the conductivity of the gas sensor raises along with the inflammable gas concentration increases. MQ-2 performs a good detection to different inflammable gases such as natural gas, especially sensitive to liquefied gas, propane and hydrogen.

The resistance of the sensor is different depending on the type of the gas.

The gas sensor module MQ-2 has a built-in potentiometer that allows you to adjust the sensor digital output (D0) sensitivity according to how accurate you want to detect gas.

The voltage that the sensor outputs changes accordingly to the smoke/gas level that exists in the atmosphere. The sensor outputs a voltage that is proportional to the concentration of smoke/gas.

In other words, the relationship between voltage and gas concentration is the following:

  1. The greater the gas concentration, the greater the output voltage.
  2. The lower the gas concentration, the lower the output voltage.

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.

See more info about gas sensors here.

See the specification of gas sensor module MQ-2 here.

Signals and connections of the Gas Sensor MQ-2

GND - connects to ground

D0(DOUT) - digital output (0 or 1)

A0(AOUT) - analog ouput (0-1023)

VCC - connects to DC +5V supply

Signals and connections of LED

The operating voltage of the LED is 1.8V and the operating current is 10mA-20mA. The Arduino Uno board can supply 5V or 3.3V power. We will use 5V for this project, so the minimum resistance of the current limiting resistor should be (5 V to 1.8 V)/20 = 160 Om. The 220 Om offered in the kit is suitable and you can also choose other resistors that meet the condition. The larger the resistance is, the dimmer the LED will get.

Signals and connections of piezo buzzer

Piezo buzzer pin marked with (+) sign should be connected to Arduino Uno board digital pin which sends a signal, the other pin of active piezo buzzer should be connected to Arduino Uno board GND. If you use resistor for piezo buzzer connect it between piezo pin marked (+) sign and Arduino Uno digital pin.

Build the circuit

The following picture shows the needed connections with the Arduino Uno 

Code

In this project, release some combustible gas around the sensor and the value at A0 increases. Once the concentration of the gas exceeds a limit, D0 outputs low level and the corresponding LED will light up and buzzer will be activated. Please note that the sensor needs burn-in time so the readings can be more consistent and reliable. Enter your limit in the sketch, for the proper limit please check the sensor module datasheet. 

The arduino is reporting analog voltage levels, represented by numbers ranging from 0 (0 VDC) to 1023 (5 VDC) in increments of 0.0049 VDC. (https://www.arduino.cc/en/Reference/analogRead)

If you want to get PPM, you will need to remap values from 0-1023 to the appropriate ppm, for example - gasvalue=map(Analogstate, 0,1023, 0, 255) 

To calibrate, you would need to enclose the sensor in some sort of chamber, and then introduce a known concentration of a gas into the chamber (dangerous if you don't know what you are doing). The safer method is to compare readings with a known working meter, which provides a ppm readout.

Bear in mind, that without calibration, these values may be off. These are cheap sensors, so quality control is questionable. You should not rely on this for actual life safety. 

Step by Step instruction

  1. Open Arduino IDE.
  2. Plug your Adruino Uno board into your PC and select the correct board and com port
  3. Open up serial monitor and set your baud to 9600 baud
  4. Verify and upload the the sketch to your Adruino Uno board.
  5.  ignite a lighter. Then the sensor detects the gas emitted. Thus, the LED on the gas sensor and that attached to pin 13 on the SunFounder Uno board will light up. Also you can see the value at A0 and D0 printed on Serial Monitor.
    Note: It is normal that the gas sensor generates heat. Actually, the higher the temperature is, the sensor is more sensitive. 
    Ignite a lighter close to the sensor module. The sensor detects the gas emitted and the LED on the gas sensor and the red LED will light up and the buzzer will be on. You can see the value at A0 and D0 printed on Serial Monitor. If no gas detected the green LED will be on and buzzer will be off. It is normal that the gas sensor generates heat. Actually, the higher the temperature is, the sensor is more sensitive. 

Summary

We have learnt how to connect gas sensor MQ-2 module,LEDs, active piezo buzzer to Arduino board.You can use this project code to read values from all MQ gas sensors (MQ-2, MQ-3, MQ-4, MQ-5, MQ-6, MQ-7, etc).

Library:

  • No libraries required for this project

Sketch:

  • See attachments on the begining of this project description. 


Other projects of Lex C
Easy Basics: Project 057a ACR122U NFC Reader of Lex C, Not selected 17-01-2018

Published at 13-09-2017
Viewed: 1646 times