Interfacing MQ-4 Gas sensor with evive

gas sensor
About This Tutorial
In this tutorial we will interface MQ-4 Gas sensor module with evive and if Gas concentration exceed specific concentration we will glow led
Tutorial Info

Components Required

ImageComponentQuantityAvailable in Kit
evive1
USB A-B Cable1
Male to Female Jumper Cable 20cm1
MQ4 Gas Sensor1
  • None

Introduction

Gas sensors are designed to measure the concentration of gases in the environment. There are many different types depending on what you want to measure. In our case, we will be using MQ-4 Gas sensor which can measure Liquefied Petroleum Gas(LPG), Hydrogen (H2), Carbon Monoxide (Co) and smoke concentrations.

MQ series sensor uses a small heater inside with an electrochemical sensor in order to measure a different kind of gases combination. They can be calibrated, but, in order to do that, a known concentration of measured gas or gases is needed. In our case, we will test it, as it comes from the producer without any additional calibration. The MQ-4 Gas sensor has a built-in variable resistor that changes its value according to the concentration of gas. If the concentration is High, the resistance decreases,  if the concentration is low, the resistance increases. Besides the built-in resistor, it is necessary to include load resistor, Load resistor serve to adjust sensor sensitivity and accuracy, it’s value can range from 2k ohm to 47 k ohm higher the value, the more sensitive sensor becomes.

Circuit diagram

 

  • Connect “VCC” of the MQ-4 gas sensor with “VCC” of evive 
  • Connect “GND” of MQ-4 gas sensor with “GND” of evive
  • Connect “Aout ” pin of MQ-4 gas sensor with ” A0″ pin of evive

 

Equations

MQ-4 Gas Sensor Sensitivity Characteristics:

Graph

The graph tells us the concentration of a gas in part per million (ppm) according to the resistance ratio of the sensor (RS/R0).

  1. RS is the resistance of the sensor that changes depending on the concentration of gas.
  2. R0 is the resistance of the sensor at a known concentration without the presence of other gases, or in the fresh air.

Calculation

RS = [(Vin x RL) / Vout] - RL
  1. Vin is 5V in our case.
  2. RL is 10 kOhm
  3. Vout is the analog voltage reading from the sensor

From the graph, we can see that the resistance ratio in fresh air is a constant:

RS / R0 = 4.4 ppm  

To calculate R0 we will need to find the value of the RS in the fresh air using the above formula. This will be done by taking the analog average readings from the sensor and converting it to voltage. Then we will use the RS formula to find R0.

R0 = RS / 4.4

Gas concentration for LPG is given by:

log(x) = [log(y) - b] / m

where x is the gas concentration, y is the RS/RO ratio, b = 1.133 and m = -0.318.

However, in order to get the real value of the gas concentration according to the log-log plot we need to find the inverse log of x:

x = 10 ^ {[log(y) - b] / m}

PictoBlox (Scratch Program)

evive Notes Icon
Note: We will write the code in Stage Mode.

There are two steps to calculate PPM for the gas:

  1. First, we will calculate the value of R0. To calculate R0 we need to find out the value of Rs in the fresh air, this will be done by taking analog average readings from the sensor and converting it into the corresponding voltage value, then we will use above formula to calculate R0, wait until we get the stable value of R0. Make this script in the PictoBlox to get the value of R0.
    Calculating R0
    Download the program from here: Gas Sensor Calculating R0 value
  2. After that, we will use the above-calculated value of R0 to find out the concentration of gases in ppm. If the ppm is higher than 2000, then the Pin 13 LED will glow.
    evive Notes Icon
    Note: You have to replace the value of R0 in the program with the value you have got in the previous program.

    Calculating PPM
    Download the program from here: Gas Sensor Calculating PPM

Arduino IDE code

The code is divided into two parts

  1. First, we will calculate the value of R0. To calculate R0 we need to find out the value of Rs in the fresh air, this will be done by taking analog average readings from the sensor and converting it into the corresponding voltage value, then we will use above formula to calculate R0, wait until we get the stable value of R0.
  2. After that, we will use the above-calculated value of R0 to find out the concentration of gases in ppm. If the ppm is higher than 2000, then the Pin 13 LED will glow.

Expected Result

Share this Tutorial
Share on facebook
Facebook
Share on twitter
Twitter
Share on google
Google+
Share on pinterest
Pinterest
Share on reddit
Reddit
Share on print
Print
Related Projects & Tutorials
ldr circuit
How to interface LDR sensor with evive ?
The tutorial will shows how to interface ldr sensor with evive and controlling the led state using the sensor.How does ldr sensor works? How to control lights using ldr sensor? All the answers are given in this tutorial.Let's begin...
LCD setup with evive
How to interface 16 X 2 LCD with evive?
This tutorial discusses how we can interface 16 X 2 with evive . How we can display the data on the lcd? All the answers are given in this tutorial.LET'S BEGIN....
All articles loaded
No more articles to load
Featured Projects
DIY Mini Safe Locker Using Servo
DIY Mini Safe Locker Using Servo

Make your own DIY mini-safe locker using components from the evive Starter Kit and control it using evive’s slide switch!

All articles loaded
No more articles to load

Leave a Reply

Close Menu
×

Cart