LPG Gas Sensor Interfacing with PIC16F877A

In this tutorial we are going to see LPG Gas Sensor Interfacing with PIC16F877A.

Prerequisites

Before start this tutorial we should know below topics. If you know already, please go further.

Components Required

Introduction

There are many gases available in environment. Like that there are many sensors available to detect particular gas. In this tutorial, we are going to detect LPG gas. So we need to use MQ-2 sensor. Before that we will see the sensors available to detect gas.

lpg-gas-sensor LPG Gas Sensor Interfacing with PIC16F877A

Features

  • Operating Voltage is +5V
  • Can be used to Measure or detect LPG, Alcohol, Propane, Hydrogen, CO and even methane
  • Analog output voltage: 0V to 5V
  • Digital Output Voltage: 0V or 5V (TTL Logic)
  • Preheat duration 20 seconds
  • Can be used as a Digital or analog sensor
  • The Sensitivity of Digital pin can be varied using the potentiometer

Sensors available to detect different Gases

Sensor NameGas to measure
MQ-2Methane, Butane, LPG, Smoke
MQ-3Alcohol, Ethanol, Smoke
MQ-4Methane, CNG Gas
MQ-5Natural gas, LPG
MQ-6LPG, butane
MQ-7Carbon Monoxide
MQ-8Hydrogen Gas
MQ-9Carbon Monoxide, flammable gasses
MQ131Ozone
MQ135Air Quality
MQ136Hydrogen Sulphide gas
MQ137Ammonia
MQ138Benzene, Toluene, Alcohol, Propane, Formaldehyde gas, Hydrogen
MQ214Methane, Natural Gas
MQ216Natural gas, Coal Gas
MQ303AAlcohol, Ethanol, smoke
MQ306ALPG, butane
MQ307ACarbon Monoxide
MQ309ACarbon Monoxide, flammable gas

Selecting between Sensor type and module type

When it comes to measuring or detecting a particular Gas the MQ series Gas sensors are the most commonly used ones. These sensors can either be purchased as a module or as just the sensor alone. If you are trying to only detect (not measuring ppm) the presence of a gas then you can buy it as a module since it comes with an op-amp comparator and a digital out pin. But if you planning to measure the ppm of a gas it is recommended to buy the sensor alone (without module).

Working with Gas Sensor

Using an MQ sensor it detects a gas is very easy. You can either use the digital pin or the analog pin to accomplish this. Simply power the module with 5V and you should notice the power LED on the module to glow and when no gas it detected the output LED will remain turned off meaning the digital output pin will be 0V (LOW). Remember that these sensors have to be kept on for pre-heating time (mentioned in features above) before you can actually work with it. Now, introduce the sensor to the gas you want to detect and you should see the output LED to go HIGH along with the digital pin, if not use the potentiometer until the output gets high. Now every time your sensor gets introduced to this gas at this particular concentration the digital pin will go high (5V) else will remain low (0V).

You can also use the analog pin to achieve the same thing (We are not covered this part in this tutorial). Read the analog values (0-5V) using a microcontroller, this value will be directly proportional to the concentration of the gas to which the sensor detects. You can experiment with this values and check how the sensor reacts to different concentration of gas and develop your program accordingly.

LPG Gas Sensor Interfacing with PIC16F877A

Connection

GAS Sensor

  • Vcc – 5v
  • Gnd – Ground
  • DO – RD0 (PORTD.0)

LCD

  • RS – RC0
  • RW – RC1
  • EN –RC2
  • Data Lines – PORTB

lpg-gas-sensor-interfacing-with-pic16f877a LPG Gas Sensor Interfacing with PIC16F877A

Source Code

If it is detecting LPG gas in front of this sensor, LCD will display “Gas Detected”.

Applications

  • Detects or measure Gases like LPG, Alcohol, Propane, Hydrogen, CO and even methane
  • Air quality monitor
  • Gas leak alarm
  • Safety standard maintenance
  • Maintaining environment standards  in hospitals

NOTE: if you are planning to measure the ppm of a gas then you should take the analog output from AO pin and need to convert that analog value to digital value and display that using ADC.

Download our new Android app. You can learn all Embedded Tutorials from your Android Phone easily.

Click Here to Download App!