HW MQ 2 Gas detecting sensor

Dear Community,

this is my second article, first I wrote here about the MQ 3 Alcohol Sensor, and my second thread has the exact same setup for connection to my arduino, so to save my time look here:
MQ-3 Alcohol Sensor (datasheet, circuit plan, code) - Using Arduino / Sensors - Arduino Forum

I will update my program code tomorrow, today I just want to relax :slight_smile:

I just started the pre heating time, which is again given with 24 hours to have better results tomorrow.

datasheet here:

Just one question to the forum members, does anybody know if you can find out which gas you just are detecting? I mean you see the analog value in parts per millions but the different concentrations which can be detected overlap each other...

Does anybody has a clue here? Is it maybe possible with the digital out pin of the sensor?

I new in sensor electronics, but maybe we have some people with more knowledge here in the forum?

Yes, by using a sensor that can actually report the contents of a gas mixture. They are very expensive.

Hi jremington,

thank you for your feedback, this was also my second guess, my sensor pack was very cheap, I only paid a few euro for them.

Since each MQ sensor responds to several different gases, you can only determine that something has changed in the environment. Even then you have to be careful, because the sensor's response is not very stable.

However, the different sensor types vary in their response to gas mixtures, which leads to some possibly useful applications. You might find this article interesting (I did): https://web.archive.org/web/20180513090020/http://www.maskau.dk/projects/electronic-nose

Hi jremington,

I just made a quick search with what kind of gas I can test the sensor today.

My camping cooker is using:
Maximum Gas Kartuschen Universal Gaskartusche 227g π Butan Gaskartuschen TÜV π geprüft Typ MSF-1A
a lighter is using:
Daher wird häufig ein Gasgemisch aus Propan und Butan für Feuerzeuge hergestellt. Mit einem solchen Gemisch der zwei Gase ist das Verwenden des Feuerzeuges jederzeit und bei allen Temperaturen möglich. Isobutan ist das hochwertigste Feuerzeuggas, welches besonders rein ist.

my last test is H2, I will create a bit of H2 with my transformer.

I will give you feedback when I'm done with the checks.

So here comes the update:
first I made a quick search in safety datasheets for propan and butan, to find out the ppm values for dangerous conditions:


This is included partly in my code:

/* MQ-2 Gas detecting Sensor Circuit with Arduino */
int AnalogPin = 0; //the AOUT pin of the gas concentration sensor goes into analog pin A0 of the arduino
float value1 = 0;
float check=0;
void setup() {
  Serial.begin(115200);//sets the baud rate
  pinMode(AnalogPin, INPUT);//sets the pin as an input to the arduino
//delay(86400000); // this it the pre heat time, according to the datasheet
}
void loop()
{
 value1 = 0;
 value1 = analogRead(AnalogPin); //reads the analaog value from the gas concentration sensor AOUT pin I guess it is Parts per Million
 Serial.print("Gas concentration of: LPG, i-butane, propane, methane ,alcohol, Hydrogen, smoke in parts per million: ");
 Serial.println(value1);//prints the gas concentration
// here comes the security check according to gas safety datasheet
check = value1 / 4000;
Serial.println(check);
if ( check > 0.99)
{ 
  Serial.println("Danger due to high gas concentration, explosive environment, open the windows, and don't use electric equipment, escape from the building!");
  delay(2000);
}
else
{
 delay(1000);
}
//according to safety datasheet you could create the middel value for 8 hours, and check if the concentration is over 2000ppm, which will be also dangerous
}

What I learned from programming here is, don't use "," for values you need to use "." and also that you can't devide float / int values, it only worked with float / float values when I had one float value.

First test with my lighter is done, I have around 900ppm for the open valve of my lighter next to the sensor.

More checks later on.

/* MQ-2 Gas detecting Sensor Circuit with Arduino */
int AnalogPin = 0; //the AOUT pin of the gas concentration sensor goes into analog pin A0 of the arduino
float value1 = 0;
float check=0;
float wertsumme=0;
float mittelwert=0;
int i=0;
void setup() {
  Serial.begin(115200);//sets the baud rate
  pinMode(AnalogPin, INPUT);//sets the pin as an input to the arduino
//delay(86400000); // this it the pre heat time, according to the datasheet
}
void loop()
{
 value1 = 0;
 value1 = analogRead(AnalogPin); //reads the analaog value from the gas concentration sensor AOUT pin I guess it is Parts per Million
 Serial.print("Gas concentration of: LPG, i-butane, propane, methane ,alcohol, Hydrogen, smoke in parts per million: ");
 Serial.println(value1);//prints the gas concentration
// here comes the security check according to gas safety datasheet
check = value1 / 4000;
Serial.println(check);
if ( check > 0.99)
{ 
  Serial.println("Danger due to high gas concentration, explosive environment, open the windows, and don't use electric equipment, escape from the building!");
  delay(2000);
}
else
{
 //delay(1000);
}
//according to safety datasheet you could create the middel value for 8 hours, and check if the concentration is over 2000ppm, which will be also dangerous, I just wrote a code for middel value for 5 seconds, don't want to wait for 8 hours now
for (i=1; i<51; i++)
{
  if (i==1)
  { wertsumme=0;
  }
  wertsumme= wertsumme + value1;
  if (i==i)
  {delay(100);
  }

  if (i==50)
  {
    mittelwert=wertsumme / 50;
    Serial.print("Gas concentration middel value for 5 seconds in parts per million: ");
    Serial.println(mittelwert);
  }
}

}

Here is the code for the middel value of 5 seconds for the gas concentration.

Hey update, I just checked the sensor with butan gas, from my camping cooker, the gas is not 100% pure, they add a additive with bad small to be warned if something is escaping from the gas tanks.

The value went up to ~400ppm, and then I stopped the whole check and opened my windows.

I think this datasheet which I uploaded here is quite stupid, because if I have a burning mixture with 400ppm, to set the limit to 2k and 4k ppm is extremely dangerous.

Please don't rely on that datasheet, I don't know why the safety values are that high.

so I made a second check after reading that the minimum mixture fur lower burnable limit of butan is 15.000ppm (1,5%).

What I found out now, the sensor is total crap, the mixture from the camping cooker is for sure 100% burnable so it should be more over 15.000ppm, but the value only showed 458ppm.

Please save your money and don't buy it. The alcohol sensor MQ 3 was a bit more accurate.

Try 72 hours of burn-in and check whether the "clean air" reading changes much.

Hi I guess the sensor is just too bad to be exact. I was talking to my uncle yesterday and he said they use these kind of sensors at work for machine environment detection and a real working sensor with some what exact values costs around 100€.

If used carefully, those inexpensive sensors can tell you if the gas mixture has significantly changed, but not much else. I would never trust them.

If you want "somewhat exact" measurements, then you do have to pay a lot more.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.