MQ sensors

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
Post Reply
IHOXOHI
Posts: 119
Joined: Sat Apr 25, 2020 7:31 am

MQ sensors

Post by IHOXOHI » Sat Jul 11, 2020 2:35 pm

Hi,

I tried to use MQ sensor... For moment the MQ-5 and the MQ-2.

I need to calibrate them correctly...

In datasheet appears graph with 3 or 4 gas mesurements...

But, I don't understand the fact that there is only one sensor for all differents gas...

It means that all time you record all gas... No way for known values for only one gas!

It's a joke! It isn't possible to calibrate them correctly in this situation!

Am I wrong?

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: MQ sensors

Post by kevinkk525 » Sat Jul 11, 2020 3:48 pm

I once bought a MQ-5 too to detect gas in my appartment. Never got it implemented though..

This link was interesting for me: https://osoyoo.com/2018/11/15/arduino-l ... as-sensor/

From that page:
The sensor value only reflects the approximated trend of gas concentration in a permissible error range, it DOES NOT represent the exact gas concentration. The detection of certain components in the air usually requires a more precise and costly instrument, which cannot be done with a single gas sensor. If your project is aimed at obtaining the gas concentration at a very precise level, then we do not recommend this gas sensor.
So you can use this cheap sensor to detect if there is gas but you may not know which kind of gas and how much exactly. It'll be enough for a general gas alarm sensor but anything else might be difficult, but you can read about it here https://playground.arduino.cc/Main/MQGasSensors/
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

IHOXOHI
Posts: 119
Joined: Sat Apr 25, 2020 7:31 am

Re: MQ sensors

Post by IHOXOHI » Sat Jul 11, 2020 4:04 pm

Thanks Kevin for yours goods resources.

I think that I understood that you can detect nearly correctly just one gas in a same time when you adjust the level of resistance for this gas and not the others. Especially if you calibrate the sensor with a mathematic relation to obtain a precise concentration.

A lots of time... Maybe I will take it and report all requirements for each gas...

IHOXOHI
Posts: 119
Joined: Sat Apr 25, 2020 7:31 am

Re: MQ sensors

Post by IHOXOHI » Sat Jul 11, 2020 7:46 pm

Yop,

So, I have done it for MQ-5 with only the CO value for example, like that:
After read the max original value from an "adc.read()" (because usually the CO concentration is the lower, so it need the lower resistance to obtain more precision (wich need to turn, like time, the resistance of the sensor to the max), I have obtained 759 with my sensor for a "real" concentration of 30 ppm approximatively (view my previous post on 3 gas sensor analogic from china).

So to have approxamitvely 30 ppm for my MQ-5, I have :
"
value = adc.read()
volt = value * 4.95 / 4095
co = round(volt * 30)
print(co)
"
(There is a coincidence with the 30 number there).
Finally, I think that MQ-sensors could be goods, but these need a calibration with an other sensor for work correctly, for each gas. There isn't correlation between each different gas for the same sensor. So it couldn't be possible to calibrate a gas with a correct value of an other gas...
Otherwise, we could take "normal" (most of the time = 0 for polluants) value as true, and have an idea of changement.

IHOXOHI
Posts: 119
Joined: Sat Apr 25, 2020 7:31 am

Re: MQ sensors

Post by IHOXOHI » Mon Jul 20, 2020 10:36 am

Hi,

Finally for beeing sure, I have bought a professional sensor of CO gas...

My mq5 didn't works. No changement with differents concentrations of CO...

Otherwise, my mq2 works correctly with my method upper (level resistence to have a max value of an adc.read).
For me, or for this sensor,the code below return 0 for CO value, and get upper when I smoke on the sensor, like the professional sensor:

Code: Select all

valeur = adc.read()
    volt = valeur * 4.95 / 4095
    co = round(volt * 20) - 60
    if co < 0:
        co = 0
When I smoke I have a value around 30 ppm...
I have smoked a lot of cigaret!!!

For others gas values of mq2 sensor, I don't know. If somebody has a professional sensor for LPG or alcohol or CH4... and can test a mq2...

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: MQ sensors

Post by kevinkk525 » Mon Jul 20, 2020 12:36 pm

Hmm yeah that is why I abandoned the MQ5 sensor, couldn't really figure out how to correctly use it so I thought a professional, ready-to-use solution might be better.
But it was just for a gas heater in our appartement and we moved shortly after, so now I don't need that kind of sensor anymore, so I didn't look at it any further.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

IHOXOHI
Posts: 119
Joined: Sat Apr 25, 2020 7:31 am

Re: MQ sensors

Post by IHOXOHI » Tue Jul 21, 2020 9:45 pm

Yop,

Finally, I'm not sure...

For me, MQ5 works too for CO gas.
my code:

Code: Select all

valeur = adc.read()
    volt = valeur * 4.95 / 4095

    LPG = round(volt * 100)
    co = LPG // 7 - 13
    if co < 0:
        co = 0
If it's all right, you should have 0 ppm of CO gas, and nearly 20 ppm when you smoke on the sensor (the value of my "valeur" is 771 for 0 ppm). I will test with an other co gas production like incense (?) or fumigen???

I have payed for a professional LPG sensor... I will receive it in few days...
The price is completly different from mq sensor! But I need just one for calibrate all other mq.

I don't know if there is a correlation between different mq5... I have bought an other too...

IHOXOHI
Posts: 119
Joined: Sat Apr 25, 2020 7:31 am

Re: MQ sensors

Post by IHOXOHI » Mon Jul 27, 2020 5:06 pm

The subject is finally closed...

I have received my professional LPG sensor...

It's not possible to doesn't have influences of differents gas on mq sensor. So, you can't measure other thing than all gas of the sensor.

For LPG gas, you can have an approximative value but for CO ; it's crazy.

For detect pollution, like I wanted, mq sensor can't do the job.

Post Reply