AN-1133 Flammable Gas Monitor

Described here is a flammable gas detector using a GreenPAK™ IC. It monitors continuously, which makes it suitable for industrial use. The detector includes a temperature failsafe to alert when readings are compromised because of ambient temperature deviation.

MQ-2 Sensor background

The MQ-2 sensor can detect a wide range of gases such as LPG, Propane, Methane, Alcohol, Hydrogen and Smoke etc. A module with MQ-2 (Figure 1) is available having a built-in potentiometer for the load resistance. This allows adjustment of the resolution.

MQ-2 module

Figure 1. MQ-2 module

The MQ-2 datasheet shows the sensing circuit implementation with a Load Resistance (RL), as shown in Figure 2.

Sensor application schematic

Figure 2. Sensor application schematic

The graph in Figure 3 shows the expected sensor response to various gases (in controlled Humidity and temperature).

Response curves for various gases Sensor response vs. Temperature
Figure 3. Response curves for various gases Figure 4. Sensor response vs. Temperature

Table 1 shows the PIN functions. D0 (Digital output) will not be used this time since its function is to only detect the presence of a gas, but not its quantity. We will be using A0 (Analog out) so that we can set a threshold corresponding to a permissible concentration.

PIN Function
VCC 5V supply
GND Ground
A0 Analog Output
D0 Digital Output


Table 1. Pin function

Ambient temperature does affect the MQ-2 behavior, so we will use the LM35D to let us know when the room temperature exceeds 30° C. This will be a way to alert us that the readings have moved past the calibration setting.

Testing the sensors

After powerup and several minutes warmup time, the MQ-2 sensor output stabilized at approx. 0.250 V with no flammable gas present, (see Figure 5).

The first test is done using the LPG fumes from inside a cigarette lighter. The lighter was nearly empty, but with the last fumes of the LPG gas, we were able to see a noticeable change in the stabilized output value of the sensor. We measured a delta of almost 0.75V (see Figure 6).

From MQ-2 datasheet information, we can extract the following equations:

RS(Neutral) (1)

V Input is always going to be 5V and our stabilized voltage/output voltage will be 0.25V. This Yields an RsNeutral of 19.

Going back to Figure 3, we can see that the Rs/Ro ratio of clean air is 9.8. That allows us to obtain the Ro using the formula:

Ro (2)

In our case Ro yields a value of 1.93.

Note that these values don't have units, and are only referencing to the Chart described in Figure 3. To confirm this, we will be using the 1V value sensed from the LPG fumes.

Applying the Formula again (1).

RS(LPG) (3)

RsLPG= 4 and now when we look for the Rs/Ro ratio again, we get a ratio of 2.07.

Going back to the datasheet and Figure 3, we can see that the LPG curve has its first point at 200 ppm. Also, the Rs/Ro ratio closely aligns with the ratio described by the graph.

Implementing the LM35D is straightforward since its output follows a very linear change of 10mV/C°. Figure 7 shows the reading for a typical room temperature measurement (at almost 25° C).

MQ-2 output with no flammable gas MQ-2 output with flammable gas LM35D output at 25C
Figure 5. MQ-2 output with no flammable gas Figure 6. MQ-2 output with flammable gas Figure 7. LM35D output at 25C

Implementation of an Alarm using the MQ-2 for LPG gas

We select a ppm value for the LPG curve and correlate it with the chart shown in Figure 3. For this application, let us select a value of 700 ppm.

The Rs/Ro for it will be almost 0.9. Using the previously mentioned values, we can see that Rs = Ro*0.9 = 1.737 Now, when we substitute this value in equation (1), we get a Voltage threshold of 1.82V.

Also, (as part of the temperature alert), when the LM35D gives us 300mV, the GreenPAK will show a different color on the RGB LED.

Along with this Appnote, a .gp5 file is available which contains the configuration shown in Figure 8.

The signal LM35D_Threshold and MQ-2_Threshold were faster than the Inverted ones coming from the blocks 2-L0 and 2-L1. Thus, first ones were delayed using two inverters and it led to LM35D_delayed and MQ-2_delayed. Both now have enough delay time between them for the latches to work reliably.

This design uses an RGB LED where the color represents the status. GREEN means that there is no LPG gas present; BLUE means that the room temperature is higher than the normal sensing conditions (causing a change on the readings, as shown in Figure 5); and RED shows that the LPG threshold has been reached.

Schematic in GreenPAK Designer

Figure 8. Schematic in GreenPAK Designer

Along with the red color, an Alarm will also start sounding.

The latches get reset when nReset is LOW. When the Reset button is not pressed, its value is LOW, so we invert its signal to get nReset which will be HIGH. This will ensure normal behavior of the latches until the Reset Button is Pressed.

Figure 9 shows the complete detector design operating in clean air.

Complete detector design in clean air

Figure 9. Complete detector design in clean air

Possible modifications of this design

The current design proposes the use of the MQ-2 Gas sensor as a broader solution to detect several kinds of gases. The downside of the MQ-2 is that it consumes 150mA at 5V. As a result, the MQ-2 is better suited for continuous monitoring using a wall adapter.

An alternative sensor is the CCS801 from CMOS SENSORS. In contrast to the MQ-2 5V oven, the CCS801 oven works with a peak voltage of only 1.8V. During normal and datasheet specified characteristics, the CCS801 has an average power consumption of 0.9mW.

The CCS801 works like the MQ-2; it changes its resistance according to the concentration of the desired gas present. However, unlike the MQ-2, its warmup/stabilization period is shorter, and that allows us using a PWM to power the resistance heater. This also makes more practical the use of WAKE/SLEEP cycles for the ACMP power savings.

The CCS801 load resistors chosen are shown in Figure 10.

CCS801 resistor setting

Figure 10. CCS801 resistor setting

PIN 1 along with PIN 3 of the CCS801 represent the sensing resistor. A simple voltage divider can be used to obtain the Rs Neutral of this sensor. The formula is shown in Figure 11.

CCS801 resistor calculation

Figure 11. CCS801 resistor calculation

The value of Rs Neutral can now be used along with the chart in Figure 12 to obtain a ratio proportional to the desired concentration of gas.

While the CCS801 can’t detect a wide range of gases, it can still detect CO; the main component of smoke.

CCS801 response chart

Figure 12. CCS801 response chart


It was demonstrated that the GreenPAK5 versatility allows the designer to customize an analog front end for interface to the MQ-2 and similar sensors. Designing industrial detectors of many types are within reach because of the flexibility of the circuit resources available within the GreenPAK family of products.

About the Author

Name: Onésimo Ivan Fernandez

Background: Ivan is a mechatronic engineer graduated from UDLAP and focused on electronics and programming. During his senior year in college he became a finalist in the 2016 INFChallenge. He is currently pursuing a Masters degree in the field of Electronics and Computer Science.




See full list of Application Notes

© 2017 Silego Technology. 1515 Wyatt Drive, Santa Clara, CA 95054.
Facebook LinkedIn Twitter YouTube Google