Home ARDUINO How to Build Gas sensing system with Arduino, 16X2 LCD and MQ2

How to Build Gas sensing system with Arduino, 16X2 LCD and MQ2

0

The MQ2 sensor is a gas module for the detection of hydrogen, liquefied petroleum gas, smoke, carbon monoxide and alcohol. It has high sensitivity and fast response. The MQ2 sensor is a gas module for the detection of hydrogen, liquefied petroleum gas, smoke, carbon monoxide and alcohol. It has high sensitivity and fast response time to measure and acquire data. Sensitivity can be adjusted by the potentiometer behind it.

What is the MQ-2 smoke sensor?

The MQ-2 smoke sensor is sensitive to smoke and the following flammable gases:

  • LPG
  • Butane
  • Propane
  • Methane
  • alcohol
  • hydrogen

The resistance of the sensor varies depending on the type of gas.

How does it work?

The voltage output by the sensor varies corresponding to the level of smoke/gas present in the atmosphere. The voltage output by the sensor is proportional to the concentration of smoke/gas.

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

  • The greater the gas concentration, the larger the output voltage

Low gas concentration and low output voltage

The output can be an analog signal (A0) that can be read using the Arduino’s analog input or digital output (D0) and can be read using the Arduino’s digital inputs. Calculate the accuracy of the gas you want to detect.

Things used in this project

Hardware components

Software apps and online services Requirements

 Connections

Arduino              MQ2

  • AO                       A0
  • 5V                     VCC
  • GND                   GND

Upload source

 

#include <MQ2.h>

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

//I2C pins declaration

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

int Analog_Input = A0;

int lpg, co, smoke;

 

MQ2 mq2(Analog_Input);

 

void setup(){

Serial.begin(9600);

lcd.begin(16,2);//Defining 16 columns and 2 rows of lcd display

lcd.backlight();

mq2.begin();

}

void loop(){

float* values= mq2.read(true); //set it false if you don’t want to print the values in the Serial

//lpg = values[0];

lpg = mq2.readLPG();

//co = values[1];

co = mq2.readCO();

//smoke = values[2];

smoke = mq2.readSmoke();

lcd.setCursor(0,0);

lcd.print(“LPG:”);

lcd.print(lpg);

lcd.print(” CO:”);

lcd.print(co);

lcd.setCursor(0,1);

lcd.print(“SMOKE:”);

lcd.print(smoke);

lcd.print(” PPM”);

delay(1000);

}

LEAVE A REPLY

Please enter your comment!
Please enter your name here

7 + one =