Arduino: Gas Sensors MQ Series Principle

Post Reply
tong
Site Admin
Posts: 2386
Joined: Fri 01 May 2009 8:55 pm

Arduino: Gas Sensors MQ Series Principle

Post by tong »

001 Diagram.png The virgin sensor require to run for 24 hours (the 1st time initialization).
The heater require 5V 800mW (160mA) which is a bit hot while working.
002 RS.png Updated: The MQ-2 sensor resistance (RS) will vary between 3 - 30 kohm while measuring gas. I don't known what it mean. Normally when measuring the clean air, the MQ-2 sensor resistance (RS) just only 10 kohm and reduce when found the gases. Look at the graph (post #5), if RO is fixed, the RS should be lowest to 0.3 kohm. The prefered range should be 0.3 to 10 kohm.

The MQ-2 sensor resistance will working as the Voltage Dividers.
003 Voltage-Divider.png
tong
Site Admin
Posts: 2386
Joined: Fri 01 May 2009 8:55 pm

Re: Gas Sensors MQ Series Principle

Post by tong »

RS while measuring gas can find from VOUT and the fixed RL.
The best RL value for the entire sensitivity range can find from the equation below:
004 RL.png
tong
Site Admin
Posts: 2386
Joined: Fri 01 May 2009 8:55 pm

Re: Gas Sensors MQ Series Principle

Post by tong »

Updated: If we choose RS (min) = 0.5 kohm and RS (max) = 10 kohm, the best RL will be 2.2 kohm.
004 RL v2.png These are the RL calculation from the RS max & min range:

RS (min) = 0.5 kohm
RS (max) = 10 kohm
005.png The best RL value should be 2.2 kohm which give the analog VOUT 649 scales/spreads. It is the highest resolution.
006 Voltage-Divider-2K2-184.png 007 Voltage-Divider-2K2-833.png
tong
Site Admin
Posts: 2386
Joined: Fri 01 May 2009 8:55 pm

Re: Gas Sensors MQ Series Principle

Post by tong »

(Reserved)
tong
Site Admin
Posts: 2386
Joined: Fri 01 May 2009 8:55 pm

Re: Gas Sensors MQ Series Principle

Post by tong »

To calibration, we need to find the RO value while measuring the clean air.
Since we known the ratio of the clean air from the graph is 9.83, then we can calculate RO from the equation below:
008 RO.png Now we can find the concentrations (ppm) of any gas from the graph from RS/RO ratio.
009.png 1. Take two points from gas graphs.

CO (x1, y1) = (log10200, log105.14)
CO (x2, y2) = (log101000, log103.14)

SMOKE (x1, y1) = (log10200, log103.43)
SMOKE (x2, y2) = (log101000, log101.89)

LPG (x1, y1) = (log10200, log101.67)
LPG (x2, y2) = (log101000, log100.78)

2. Convert to base10

CO (x1, y1) = (2.3, 0.71)
CO (x2, y2) = (3.0, 0.50)

SMOKE (x1, y1) = (2.3, 0.54)
SMOKE (x2, y2) = (3.0, 0.28)

LPG (x1, y1) = (2.3, 0.22)
LPG (x2, y2) = (3.0, -0.11)

3. Calculate the slope using formula:

slope = (y2-y1) / (x2-x1)

CO = (0.50-0.71) / (3.0-2.3) = -0.21/0.7 = -0.31
SMOKE = (0.28-0.54) / (3.0-2.3) = -0.26/0.7 = -0.37
LPG = (-0.11-0.22) / (3.0-2.3) = -0.33/0.7 = -0.47

4. Create array graph in format {x, y, slope} for a program code.

CO = {2.3, 0.71, -0.31}
SMOKE = {2.3, 0.54, -0.37}
LPG = {2.3, 0.22, -0.47}

5. Gas concentration (x2) can calculate using formula:

x2 = ( (y2-y1) / slope ) + x1

Gas concentration = 10^( ( (log10(Rs/Ro)-y1) / slope ) + x1 )

6. Arduino codes

Code: Select all

float Graph_CO[3]    = {2.3, 0.71, -0.31};
float Graph_Smoke[3] = {2.3, 0.54, -0.37};
float Graph_LPG[3]   = {2.3, 0.22, -0.47};

int GetPPM(float RS_RO_Ratio, float *Graph)
{
  return (pow(10,(((log10(RS_RO_Ratio)-Graph[1])/Graph[2])+Graph[0])));
}
http://exploreembedded.com/wiki/Interfacing_Gas_Sensor
https://github.com/zesteros/ArduinoAirQualityMonitor
tong
Site Admin
Posts: 2386
Joined: Fri 01 May 2009 8:55 pm

Re: Gas Sensors MQ Series Principle

Post by tong »

The FC-22 Gas Sensor Module use RL = 1 kohm.
These module will give 589 spreads.
The module also power down the heater by connected the resistor 5.1 ohm.
010 FC-22 MQ Series Gas Sensor Module Schematic.png 011 FC-22 RL.png 012 Voltage-Divider-1K-93.png 013 Voltage-Divider-1K-682.png PS: Some modules use RL = 5 kohm which give 589 spreads too.
tong
Site Admin
Posts: 2386
Joined: Fri 01 May 2009 8:55 pm

Re: Gas Sensors MQ Series Principle

Post by tong »

Code: Select all

const int MQ_PIN = A1;                 // Beware pin A4 and A5, they are SDA and SCL.
const float RL = 1.0;                  // kohm (FC-22 module = 1.0 kohm)
const float CLEAN_AIR_RATIO = 9.83;    // Taken from datasheet graph
float RS;    // kohm   
float RO;    // kohm
int ADC;     // Give value only 0 to 1023. But in fact 5V is 1024. See datasheet.
  
ADC = analogRead(MQ_PIN);
RS = RL * (1024.0 - ADC) / ADC;

RO = RS / CLEAN_AIR_RATIO;    // Do only once while measuring clean air.
tong
Site Admin
Posts: 2386
Joined: Fri 01 May 2009 8:55 pm

Re: Arduino: Gas Sensors MQ Series Principle

Post by tong »

New updated
CLEAN AIR RATIO (Taken from datasheet log graph)
MQ-2   = 9.7688
MQ-135 = 3.7941
Post Reply