Space In HIndi

 


Pages

Popular

Smoke/Gas sensor (MQ2)

 Smoke/Gas sensor (MQ2) interfacing with Arduino UNO

What is MQ2 gas sensor?

MQ2 is one of the commonly used gas sensors in MQ sensor series. It is a Metal Oxide Semiconductor (MOS) type Gas Sensor also known as Chemiresistors as the detection is based upon change of resistance of the sensing material when the Gas comes in contact with the material. Using a simple voltage divider network, concentrations of gas can be detected.

MQ2 Gas sensor works on 5V DC and draws around 800mW. It can detect LPG, Smoke, Alcohol, Propane, Hydrogen, Methane and Carbon Monoxide concentrations anywhere from 200 to 10000ppm.

 MQ2 smoke sensor Basics:

It’s very easy to use and comes with two different outputs. It is not only provide binary indication of detection of gases but also an analog representation of their concentration in air.

 The analog output voltage provided by the sensor changes in proportional to the concentration of smoke/gas. The greater the gas concentration, the higher is the output voltage; while lesser gas concentration results in low output voltage.

The analog signal from MQ2 Gas sensor is further fed to LM393 High Precision Comparator, of course to digitize the signal. Along with the comparator is a little potentiometer you can turn to adjust the sensitivity of the sensor. You can use it to adjust the concentration of gas at which the sensor detects it.

Calibrate MQ2 Gas Sensor:

To calibrate the gas sensor you can hold the gas sensor near smoke/gas you want to detect and keep turning the potentiometer until the Red LED on the module starts glowing. Turn the screw clockwise to increase sensitivity or anticlockwise to decrease sensitivity


The comparator on the module continuously checks if the analog pin (A0) has hit the threshold value set by potentiometer. When it crosses the threshold, the digital pin (D0) will go HIGH and signal LED turns on. This setup is very useful when you need to trigger an action when certain threshold is reached. For example, when the smoke crosses a threshold, you can turn on or off a relay or instruct your robot to blow air/sprinkle water.

 Interfacing of MQ2 smoke sensor with Arduino UNO

Connect VCC pin to the 5V pin on the Arduino and connect GND pin to the Ground pin on the Arduino. Connect D0 output pin on the module to Digital pin 8 on the Arduino and A0 output pin on the module to Analog pin A0 on the Arduino.

Programming 

#define MQ2

pin (0)

 float sensorValue; //variable to store sensor value

void setup()

 {

     Serial.begin(9600); // sets the serial port to 9600 

    Serial.println("Gas sensor warming up!");

    delay(20000); // allow the MQ-6 to warm up

 }

 void loop() 

{

     sensorValue = analogRead(MQ2pin); // read analog input pin 0 

     Serial.print("Sensor Value: "); 

    Serial.print(sensorValue); 

     if(sensorValue > 300) 

        {

             Serial.print(" | Smoke detected!");

         } 

    Serial.println(""); 

    delay(2000); // wait 2s for next reading 

}

The output on the serial monitor looks like:



No comments: