Вы находитесь на странице: 1из 5

Project Report

Subject: Microprocessor
Program: BS (Electrical Engineering)
Roll no: 16003019002-008
Submitted by: Abdullah shaffiq
Muzammil Ilyas
Submitted to: Sir Adnan khalid

University of Management and Technology


Sialkot
MQ-2 gas sensor interfacing with pic microcontroller
MQ-2 gas sensor or Smoke detector interfacing with pic microcontroller. How to design smoke
detector circuit using pic microcontroller? In this tutorial, you will learn how to interface smoke
detector. Smoke detector sensor is used to detect the presence of smoke and gas in surrounding. It
is also used to detect gas leakage detection in household and industrial equipment’s. MQ-2 smoke
sensor or gas sensor is suitable for detection of Hydrogen, methane and LPG related gases. In
short, it can detect combustible gases. It has a wide operating detection range. It has very high
sensitivity and very fast response rate. It can even be used in harsh environments. So you can
easily use it detect the presence of gas or smoke in your surroundings. There are many smoke
detector circuits available in market. But all these sensors are expensive.

Applications of MQ-2 smoke sensor


It has many application but some of them are given below:
 Domestic and industrial gas leakage detection
 Combustible gas leakage detection
Introduction to MQ-2 gas sensor
So now let’s start with the introduction of MQ-2 smoke sensor. The sensitivity material used in
this sensor is SnO2. It offers low conductivity in air when there is no gas present in air. If there
is a combustible gas presence in the air, MQ-2 gas sensor offers high conductivity. The
conductivity depends on the concentration of gas presence in the air. The sensor module we are
using in this tutorial has on board electronics circuit as well which converts this change in
conductivity to a output voltage of the sensor. So we will using this output voltage as reference to
assure presence or absence of gas in air. I will explain it in more details in working part of this
article.
Pin out of MQ-2 gas sensor
Pin out of MQ-2 gas sensor is given below:

 Connect Vcc >> 5v power supply


 Ground >> Ground pin of power supply
 Aout >> Analog pin of pic microcontroller

Working of MQ-2 gas sensor


As I explained earlier, MQ-2 smoke sensor offers low conductivity when no gas present in the air
and it offers high conductivity when any combustible gas is present in the air. The module we are
using in this tutorial as shown in above picture has on board electronics circuit which provides this
conductivity in the form of voltage output. When there is no has present in the air, voltage at the
output of AOUT pin will be low and when there is a gas present in the air, voltage at the AOUT
pin will be high. So we will use this AOUT output pin to detect the presence of gas in air. This
sensor also has digital output pin that is DOUT. There is a on board variable resistor in this sensor
which is used to set the sensitivity of sensor. If you rotate the variable resistor clock wise, it will
increase the sensitivity of sensor and if you rotate the variable resistor anticlockwise it will reduce
the sensitivity of sensor. We are using analog output pin in this tutorial, so we need to measure
voltage across AOUT pin. So we will connect AOUT pin to analog channel of pic microcontroller.
So now let’s see how to interface MQ-2 sensor with pic microcontroller.
MQ-2 gas / smoke sensor interfacing with pic
microcontroller
To interface this sensor with pic microcontroller, we only need to connect analog output pin of
smoke sensor with analog input pin of pic microcontroller. I am using pic16f877a microcontroller
in this tutorial. PIC18f45k22 microcontroller has built in 8 analog input channels. So We need to
use only one analog channel to measure the output voltage of sensor. Circuit diagram for
interfacing with MQ-2 gas sensor with pic microcontroller is given
below:

LCD is connected with the PORTC of pic microcontroller and whenever gas is detected it will be
displayed on LCD that gas is detected. You can also connect a buzzer with output pin of pic
microcontroller. If gas is detected, buzzer or alarm will turn on. You can also add the gsm module
to this project to get sms on your mobile number when gas is present in air. You may also like to
check:
 Buzzer interfacing with Arduino
 gsm module interfacing with pic microcontroller
 send sms using gsm module and pic microcontroller
Code for MQ-2 gas sensor interfacing with
Void main ( )
{
TRISD=0;
TRISB=0;
TRISC=1;
While (1)
{
If (PORTC.B0==1)
{
PORTD.B0=1;
PORTB.B0=0;
}
Else
{
PORT.B0=0;
PORT.B0=1;
}
}
}

Вам также может понравиться