Calibration procedure of a MQ135

Thread Starter

PsySc0rpi0n

Joined Mar 4, 2014
1,786
Hello.

I'm working now with this (ando other sensors) and I simply cannot fully understand the procedure of calibrating this sensor and also the function of the potentiometer that modules comes with when this sensor is assembled on this breakout boards.
I'm using this module specifically:
1662478371277.png
From countless articles I read I still wasn't able to fully understand the process of calibrating this sensor. It's the first time I work with it and I'm not familiar with some procedures that probably are basic for most of people.

I have a few questions I need help to get an answer:

The datasheet has a log-log plot but I'm not even sure what we can use that plot for in terms of calibration.
I understand that there are 2 parameters we need to take into consideration, which are R_0 and R_S. R_S can be computed with a formula provided in the datasheet, but it depends on R_0.
If I'm not mistaken, R_0 must be measured somehow in fresh air, meaning somewhere outside in a reasonably clean air.

1.1 - How do we measure this R_0? Do we measure it with a DMM or we need to have an Arduino to read any of the module pins?
1.2 - If it is measured with a DMM, which resistor is this one in the module?
1.3 - If it is read via sensor analogue pin, which pin is this? AO or DO?
1.4 - What meaning has the DO pin, if any?
1.5 - When we find R_0 and R_S, these 2 values are suitable to detect which gases? All or only one of them supported ones? If only one, which one?

2.1 - After we find R_0 and compute R_S, does this 2 values remain always the same no matter what gas we are trying to detect or we have to find R_0 and R_S for each gas the sensor supports?

3.1 - After we know the above answers, we will end up with either one single value to R_0 and one single value to R_S that will be used with any gas or different values for R_0 and R_S for each gas. The datasheet mentions R_S and R_L. R_0 is the same as R_S but for a specific scenario, right? 100ppm of NH3 in the clean air. Is this correct? Did I understand this correctly?

3.2 - R_S is the sensor resistance that varies according to the concentration of gases. R_0 is R_S at 100ppm of NH3 in clean air. then, R_L must be the rpot that is added to the module back side to adjust sensitivity, right?

If anyone can help me with these questions, I'll try the calibration after I fully understand the process.

Thank you
Psy

Hi Psy, added the datasheet.E
 

Attachments

Last edited by a moderator:

Thread Starter

PsySc0rpi0n

Joined Mar 4, 2014
1,786
I just read the PDF. Still not sure about the calibration process.

One question at a time:

1 - calibration process is done for a single target gas or the calibration will be usable for any of the detectable gases?
 

Ya’akov

Joined Jan 27, 2019
10,226
I just read the PDF. Still not sure about the calibration process.

One question at a time:

1 - calibration process is done for a single target gas or the calibration will be usable for any of the detectable gases?
It appears that the calibration is the differential between fresh air and the increased concentration of any particular gas. That is, Ro is the steady state resistance of the sensor in the default (unpolluted) atmosphere it is monitoring. Rs is the inversely proportions changed resistance as the concentration of the target gas increases.

So calibration is an empirical affair. You get the stable Ro after a long period of heating and rest, then you introduce the target gas which will cause a change from Ro to Rs at the given concentration of that gas. The detector doesn’t know what the gas is, just that something is different from the clean air used as the baseline.

The sensor can‘t tell you anything about which gas has been introduced, only that there has been a change, of a certain magnitude. The trimmer is for a threshold setting that lets you simply trigger the digital output of the module. This is the easiest way to use it. The analog output requires the much more complicated process outlined in the PDF.
 

Thread Starter

PsySc0rpi0n

Joined Mar 4, 2014
1,786
Rs is the inversely proportions changed resistance as the concentration of the target gas increases.
Yes, that part is clear!

So calibration is an empirical affair. You get the stable Ro after a long period of heating and rest
Is that the procedure where we need to leave the sensor for at least 24h in fresh air and then, take like a few measurements from A0, then average them and then take that R0 as the baseline? Some of the codes I seen these last days are taking averages to consider for R0 and then for the computation of RS.
 

Reloadron

Joined Jan 15, 2015
7,867
OK the simplest way to explain calibration is the comparison of a known to an unknown. Just hold that thought.

This is the data sheet for the MQ135 gas sensor and keep in mind this is a simple hobby type sensor. This is just a wide range gas sensor, They are used in air quality control equipment for buildings/offices, are suitable for detecting of NH3,NOx, alcohol, Benzene, smoke,CO2 ,etc. You leave the sensor in open air for 24 hours as a burn in period, If you look at the data sheet page 2 of 2 Figure 3 you see where ambient air is a flat line. Also note how temperature and humidity effect the output.

Since this sensor senses several gas types you choose R Load based on what you want to sense for best output. They seem to suggest 20K Ohm so a 50 K Ohm pot may be a good start.

Actual calibration involves having a "known" as your standard. They make "Gas Calibration Standards" which becomes your known. Just as an example you place the sensor in a plastic bag and inflate the bag with your standard gas sample. Measure your voltage across your R Load. Normally you would use a sample about 20% full scale, midpoint full scale and 80% full scale and that is merely an example. Less a known you have no idea what the output numbers mean.

Less a known sample you can sort of wing it. Here is an example project for CO2 using an Arduino uC.. The guess is that atmosphere is going to be about 411.29 as it supposedly was when the article was written and CO2 concentration in PPM really depends on where you happen to be. True calibration gas samples are expensive, much more than you pay for a hobby sensor.

Finally if you look at the actual code for MQ135.h the library uses:
Code:
#define ATMOCO2 414.47 //Global CO2 Aug 2021
Again, less a known calibration sample you will have at best a hobby solution.

Ron
 

Thread Starter

PsySc0rpi0n

Joined Mar 4, 2014
1,786
Since this sensor senses several gas types you choose R Load based on what you want to sense for best output. They seem to suggest 20K Ohm so a 50 K Ohm pot may be a good start.
When you refer to R_Load, you meant the potentiometer at the back of the module, right?
However, the R_Load in the project you mention is a different resistor in the module. Not the potentiometer.
And the project you mention (as others I also read yesterday), suggest to change that R_Load (which is an SMD resistor on the back of the module PCB) to a 22kΩ resistor. In that regard, I replaced the original 1kΩ resistor that comes with the sensor module with an 18kΩ one because I didn't have a 22kΩ at home to replace it.

But we have R_0 which is the same as R_S but at a specific scenario of 100ppm of NH3 in clean air, if I understand it correctly.
Then we have that rpot that I'm not sure what to call it. The datasheet obviously says nothing about it because it's not part of the sensor itself.

Regarding the rpot, this module comes with a 10kΩ. Right now, I can't runway from that. I don't have any rpot at home of the same size and with higher resistance.

Just as an example you place the sensor in a plastic bag and inflate the bag with your standard gas sample. Measure your voltage across your R Load.
This is done by reading the A0 pin of the sensor using the A0 pin of an Arduino, right?

Again, less a known calibration sample you will have at best a hobby solution.
Yes, this is just to have a proof of concept to show to the "bosses", so yeah, no worries with a hobby level outcome!
 

bidrohini

Joined Jul 29, 2022
190
I am sharing what I did some years ago. I made a CO2 meter using MQ-135. It measured the density of CO2 in ppm. I cropped the characteristic graph from the datasheet. Then I used WebplotDigitizer and microsoft excel. I derived the following equation.

RS/R0=-0.455ln(PPM)+3.1447; Rs=sensor resistance, which varies with CO2 density
Also, RS=(1024*RL/analogread(0)-RL) ; RL=Load resistance=1K in my module

Then, it was my turn to figure out R0. R0 is the sensor resistance for a particular gas at a particular density. To measure R0, I had to know the ppm also. From https://www.co2.earth › daily-co2 , I could so the density of CO2 in the atmosphere everyday.

I took my whole setup under the open sky. Uploaded the AnalogReadSerial example to the Arduino. I measured analogread(0) with the sensor connected to Arduino. And thus figured out the value of Rs from the 2nd equation.
Then from the above-mentioned website, I saw the density of CO2 in the atmosphere that particular day.
And putting the values of ppm and Rs in the 1st equation, I measured R0.

This process worked in the case of CO2. For other gasses, the method can differ.
 

Reloadron

Joined Jan 15, 2015
7,867
I am sharing what I did some years ago. I made a CO2 meter using MQ-135. It measured the density of CO2 in ppm. I cropped the characteristic graph from the datasheet. Then I used WebplotDigitizer and microsoft excel. I derived the following equation.

RS/R0=-0.455ln(PPM)+3.1447; Rs=sensor resistance, which varies with CO2 density
Also, RS=(1024*RL/analogread(0)-RL) ; RL=Load resistance=1K in my module

Then, it was my turn to figure out R0. R0 is the sensor resistance for a particular gas at a particular density. To measure R0, I had to know the ppm also. From https://www.co2.earth › daily-co2 , I could so the density of CO2 in the atmosphere everyday.

I took my whole setup under the open sky. Uploaded the AnalogReadSerial example to the Arduino. I measured analogread(0) with the sensor connected to Arduino. And thus figured out the value of Rs from the 2nd equation.
Then from the above-mentioned website, I saw the density of CO2 in the atmosphere that particular day.
And putting the values of ppm and Rs in the 1st equation, I measured R0.

This process worked in the case of CO2. For other gasses, the method can differ.
Really good stuff from a been there and done that. I believe he has your questions answered. More questions just ask.

Ron
 

Thread Starter

PsySc0rpi0n

Joined Mar 4, 2014
1,786
Thanks for the replies and know how.
I have been testing the code of the link that @Reloadron posted above and I just can't get reliable results.
I have 2 MQ135 with me.
One of them has the original 1kΩ resistor and the other one has an 18kΩ resistor (as I said above, I didn't have any 20kΩ nor 22kΩ smd resistors at home).

The sensor with 1kΩ resistor, when I run the getRZERO() part of the code, I get an average value of 53.48 (yesterday was around 66). Then, when I run the code for the PPM value, I get readings around 450ppm. But a couple of minutes later, this value decreases to something around 300 PPM or even less.
If I give it less than a second of lighter gas, the PPM values sky rockets to over 25000. Is this reasonable?

With the 18kΩ sensor, I do the same with getRZERO() and get values of exactly 113.98. And not a single digit of variation. I'm not sure this is ok, but I find it a bit strange that I get an 100% constant value of 113.98 all t he time.
And then, plugging this value in the header file and running the rest of the code for the PPM, I get even more weird values and behaviour! I get a max value of 416.02 PPM and if I give it a bit of lighter gas, the PPM value instead of sky rocket just like the other sensor, the PPM values go down... Yes, down. Then, it slowly recovers back to the same 416.02 PPM.
The same happens with isopropyl alcohol.
This is at work, but at home I think the sensor (the 18kΩ one) reacts as expected!

The only difference is that at work I am powering the 2 sensors from the laptop USBport with this board:
https://joy-it.net/en/products/SBC-POW-BB

1662720097344.png



This board apparently cannot output exactly 5V, I measure around 4.76V ~ 4.82V with the 2 sensors connected at the same time! Not sure if this small difference can play a role in the results!
 

Thread Starter

PsySc0rpi0n

Joined Mar 4, 2014
1,786
So, the sensor analogue pin will vary it's value from 0V up to 5V, according to the RS value, that in turn depends on the gases concentration, right?

From what I read, is that by changing this RL resistor from 1kΩ to a higher value, we increase the sensitivity of the sensor.
What that means to the analogue pin is that there will be a voltage divider to ground with an RL of 18kΩ instead of a voltage divider to ground of 1kΩ of the original sensor. This means that for the 18kΩ sensor, the voltage drop at this point (RL to GND) will be much higher than the sensor with 1kΩ. I think I can see something like that. Measuring this pin I get a reading around 3.7V. With the 1kΩ sensor, I get a reading of around 0.36V.

Now, why the sensor with the 18kΩ is sending to the Serial Monitor values smaller when in the presence of gases? Any ideas?
 

bidrohini

Joined Jul 29, 2022
190
So, the sensor analogue pin will vary it's value from 0V up to 5V, according to the RS value, that in turn depends on the gases concentration, right?

From what I read, is that by changing this RL resistor from 1kΩ to a higher value, we increase the sensitivity of the sensor.
What that means to the analogue pin is that there will be a voltage divider to ground with an RL of 18kΩ instead of a voltage divider to ground of 1kΩ of the original sensor. This means that for the 18kΩ sensor, the voltage drop at this point (RL to GND) will be much higher than the sensor with 1kΩ. I think I can see something like that. Measuring this pin I get a reading around 3.7V. With the 1kΩ sensor, I get a reading of around 0.36V.

Now, why the sensor with the 18kΩ is sending to the Serial Monitor values smaller when in the presence of gases? Any ideas?
These MQ-135 modules always come with 1K Ohm. Why this particular board has 18kΩ? Is it so from the beginning or you had to change the value for some reason?
 

Reloadron

Joined Jan 15, 2015
7,867
You want to measure CO2 so you really want the 1 K Ohm gone and replaced with about an 18 to 22 K Ohm. Different gasses you want to change R Load accordingly and finally keep in mind these are inexpensive hobby sensors. Also keep in mind clean air is about 400 PPM but there is a big caveat to all of this. I will bet if I measure air in NYC or LA or Cleveland, Ohio I will not get the same numbers I would get in Montanna or Kansas. The voltage you get and measure and convert to PPM is going to be a direct function of the value of R Load. Again keep in mind these sensors measure a wide range of gasses.

Ron
 
Last edited:

Thread Starter

PsySc0rpi0n

Joined Mar 4, 2014
1,786
These MQ-135 modules always come with 1K Ohm. Why this particular board has 18kΩ? Is it so from the beginning or you had to change the value for some reason?
Because datasheet sensitivity plot is for an RL of 20kΩ but I didn't have a 20kΩ or 22kΩ smd resistors at home, so I replaced the original one with an 18kΩ resistor.

You want to measure CO2 so you really want the 1 K Ohm gone and replaced with about an 18 to 22 K Ohm. Different gasses you want to change R Load accordingly and finally keep in mind these are inexpensive hobby sensors. Also keep in mind clean air is about 400 PPM but there is a big caveat to all of this. I will bet if I measure air in NYC or LA or Cleveland, Ohio I will not get the same numbers I would get in Montanna or Kansas. The voltage you get and measure and convert to PPM is going to be a direct function of the value of R Load. Again keep in mind these sensors measure a wide range of gasses.

Ron
Yes, I am aware that the sensor is cheap and will give results accordingly. I also know that different zones will return different CO2 PPM values. I'm in southest EU, so, we may have quite different results.

Anyway, the problem with one of the sensors I have (I have 2 of them) is that when I use the lighter (just the gas, not igniting any flames from the lither) next to the 18kΩ sensor, the value of PPM goes down instead of going up.
On the other hand, the 1kΩ resistor sky rockets PPM value for like 30k or more.

Why the 18kΩ sensor is bringing PPM values own instwad of raising them?
 

Reloadron

Joined Jan 15, 2015
7,867
Anyway, the problem with one of the sensors I have (I have 2 of them) is that when I use the lighter (just the gas, not igniting any flames from the lither) next to the 18kΩ sensor, the value of PPM goes down instead of going up.
On the other hand, the 1kΩ resistor sky rockets PPM value for like 30k or more.

Why the 18kΩ sensor is bringing PPM values own instead of raising them?
OK, this I simply do not understand. The gas is butane and here nor there I cannot see why changing R Load would change the output direction. Hopefully another member has an answer and we can all benefit from it but looking at an MQ0135 circuit I don't get it as to the behavior you are seeing. My read here is the actual sensor changes resistance depending on the concentration of the gas. The load resistor is in series with the sensor forming a voltage divider. The divider out is what we measure. The load resistor is a fixed value so only the sensor resistance changes. I would expect the i K load resistor to produce a lower voltage and the 18 K to produce a higher voltage since the value of R Sense should be the same. This assumes the supply can provide the current at the applied voltage for both conditions. I am obviously missing something here since it is doing what it is doing.

If I just make R sense 5K om and make R load 1 Kohm I would expect V out to be about 1 volt and if I make R load 18 K ohm I would expect to see over 4 volts so I haven't a clue what is going on.

Ron
 

Thread Starter

PsySc0rpi0n

Joined Mar 4, 2014
1,786
OK, this I simply do not understand. The gas is butane and here nor there I cannot see why changing R Load would change the output direction. Hopefully another member has an answer and we can all benefit from it but looking at an MQ0135 circuit I don't get it as to the behavior you are seeing. My read here is the actual sensor changes resistance depending on the concentration of the gas. The load resistor is in series with the sensor forming a voltage divider. The divider out is what we measure. The load resistor is a fixed value so only the sensor resistance changes. I would expect the i K load resistor to produce a lower voltage and the 18 K to produce a higher voltage since the value of R Sense should be the same. This assumes the supply can provide the current at the applied voltage for both conditions. I am obviously missing something here since it is doing what it is doing.

If I just make R sense 5K om and make R load 1 Kohm I would expect V out to be about 1 volt and if I make R load 18 K ohm I would expect to see over 4 volts so I haven't a clue what is going on.

Ron
Well, I tried something.
I removed the 18kΩ resistor and replace it with a 10kΩ and things now seems to be responding as expected.
I did the test of blowing my breath into a plastic bag, and after I get R0 value and changing RL and R0 values in the code, I could see PPM raising when I put the sensor inside the plastic bag with my breath.

So, no idea why the 18kΩ resistor was acting weird!
Values of PPM with the 10kΩ RL with the sensor inside the plastic bag with my breath went up to aroun 2000 PPM.
 
Top