Seems like if this file is missing it brakes the whole MySensors plugin.
All devices related to MySensors plugin are blank and nothing seems to update.
Deleting the device that use AirQuality.xml will make the rest work again.

@hek
ahh, that's why I cant find it... no pressure from my side to get one done but maybe we should mention this little detail on the MySensors building page just as a heads up for others since there is a sketch published and all...

@korttoma look above to S_CO2Sensor.json D_CO2Sensor.xml D_CO2Sensor.json, if you can test it...

Thanks, found the device files and got the device included again.
Seems like my MQ-2 is always reporting 0 or nothing at all. I guess I need to try to calibrate it again.
It will do the calibration every time the sensor is restarted right?
How can I calibrate the sensor if I put it somewhere where the air is not clean enough? (bring clean air in a jar? )

Maybe it would be an idea to add a calibration button to the mix and when run using the button it would save the calibration related data in the RAM so it can then always use this calibrated value and then it would not re-calibrate every time it loses power.
I have the 10k resistor between GND and A0, is this really necessary?
Does the potentiometer on the sensor board affect the analog out at all or is it only for sensitivity on the digital out?

Seems like my MQ-2 is always reporting 0 or nothing at all. I guess I need to try to calibrate it again.
It will do the calibration every time the sensor is restarted right?
How can I calibrate the sensor if I put it somewhere where the air is not clean enough? (bring clean air in a jar? wink )

this is the ongoing work, except CO2 which is known to be 399ppm (co2now.org) that should report this in clean air, for the other that should be little, and for deadly gases a full warning if this is high.

Maybe it would be an idea to add a calibration button to the mix and when run using the button it would save the calibration related data in the RAM so it can then always use this calibrated value and then it would not re-calibrate every time it loses power.

That is an option, but EEPROM has a 100k write cycle only... this is what citizensensors says about it:

1) Metal oxide gas sensors have intrinsic drift over time i.e. it is necessary to perform calibration on a regular basis.
2) Because of spread in baseline resistance, sensitivity, cross-sensitivity, temperature dependency it is not possible to apply same calibration parameters to all the sensors.
3) This type of sensor is efficient to detect change in concentration but not well adapted to absolute readings because of multiple dependency (T, RH, cross-contaminants).
4) Using smart algorithm allows indicating useful information like the correlation with CO2 in confined space like offices or buildings (see VZ-87 in attachment).
For absolute readings with high accuracy and repeatability I agree with you that you should use another technology.

From this we have the calibration issue... in another post, since they only report resistance, they say they will rebuild all their platform to address callibration issue... but since calibration depends only from a reference gas concentration... only the pre-calibrated sensors remains viable for the low cost MQ/MICS/TGS will never be really calibrated...

I have the 10k resistor between GND and A0, is this really necessary?
Does the potentiometer on the sensor board affect the analog out at all or is it only for sensitivity on the digital out?

no you can remove it, I have observed a different behavior when moving it, it looks like it is shared by both digital and analogic for the same reason. What I'd like to find is where to measure the resistance for there are often some more on the board.

Thanks, found the device files and got the device included again.
So you confirm they can be used as is ?

well, for the device in Vera I had to change the parameter "device_file" from "D_AirQuality1.xml" to "D_CO2Sensor.xml".
I don't get any errors but I also do not get any values but I guess this is because my node is not sending any values.

I'll try to look in to why my node is not reporting any value and try to remove the 10kR and see if I can measure the load resistance of my MQ-2 sensor board and maybe even remove some unnecessary components from it...

Hi All. Very interesting stuff, thanks all for sharing! I'm attempting to integrate an MQ-2, MQ-6 and MQ-135 (sensors only, no boards) using parts of epierre's sketch but I'm confused on a few things on how to set it up properly:

What resistor(s) should go between A0 and ground? Keep in mind I'm not using a sensor board with built in protection resistor. Should there be a protection resistor then an adjustable pot for calibration?

define RL_VALUE (5)
-- does this refer to the size of the protection resistor between A0 and ground?

define RO_CLEAN_AIR_FACTOR (9.83)
-- does this value need to change at all?

float Ro4 = 2.511;
-- when you say this needs to be tuned to 10k, does that mean put a pot between A0 and ground and adjust until the calibration R0 is 10k?

3- Ro is calculated on first launch expecting you do this outside.
Ro = MQCalibration(MQ_SENSOR_ANALOG_PIN);

4- this is a default value I observed here. again the datasheet recommands for MQ135 20K to be in range with their values:
we recommend that you calibrate the detector for 100ppm NH3 or 50ppm Alcohol concentration in air and use value of Load resistance that( RL) about 20 KΩ

Thanks for fast reply! I think i understand all but point #4... What do you mean by the Ro needs to be tuned to 10k? Using the adjustable resistor? Does that mean that the calibration number in fresh air at startup should ideally reach a set number, 10k?

Since I don't have access to properly calibrate the sensor against a know quantity of gas, I thought the rough calibration would occur in clean air at start up, is that correct?

@pbo as stated above, the sensors evolve in their life... let's say that the value recommended by the datasheet is the best if you can.

clean air calibration means that you should have a 0 value in clean air. Let's say that for CO2 the actual value is 399... so it should not be 0, but the clean air calibration is "assumed" quite good for LPG, SO2, NOx... that should be present in very little quantity, and again this is when the value increases a lot that it gets dangerous... there are some discussion on this above.

@Yveaux right, I opened a dispute with the seller, since I observed also no/nearly no answer to match burning with the sensor, he didn't even answer thus closing the dispute in my favor... that will be a good warning to me about those undocumented sensors comming from only one supplier without datasheet... there are other around, I shall avoid them..

@korttoma You've been lucky finding such a schema, but it is strange there is a resistance on the other side of the sensor, and the variable one is not where expected... maybe the 1K is wrong on the schema, can you mesure it on the board?

5.1 Ohm is low...

The RL here is for the voltage comparator that gives the digital output with led.

MQ-2 datasheet asks for Rs in 3KΩ-30KΩ
If this is right, then the value that the autocalibration "in clean air" should give you something around 1K.

The MQ-9 datasheet is a bit more versatile:
Power of Sensitivity body(Ps): Ps=Vc^2×Rs/(Rs+RL)^2
Resistance of sensor(Rs): Rs=(Vc/VRL-1)×RL

MQ-9: Rs(in air)/Rs(100ppm CO)≥5

I fear they are using a standard board for all sensors and that the resistance value may be wrong from this, just because they want to deliver a digital signal...

I did not find the schema, I measured the board and figured it out myself so it might be wrong.

Could you draw a schema that would show me exactly how it would preferably look so I can change it? Because I'm clearly not smart enough to understand it from your descriptions. Please explain it to me like I was 4 years old

A lot of good questions, not easy to answer! It is good you tryed it with three sensors instead of just one, and you can see there is a lot of variation from one sensor to the next of the same batch.
[...]
As to the value of Ro, that is the million dollar question. You have to have a known calibration source of CO in order to determine that! Each MQ-7 sensor will be different. The normal levels in a lab or home will be (should be!) well below the level that this sensor can detect and discriminate. It's lower limit implied in the data sheet is around 50ppm, which is where it begins to be dangerous for continuous exposure. Do read wiki and other sources about carbon monoxide and levels that can occur under different conditions.

During the weekend I did the hardware changes and tried my MQ-2 sensor again and now if I hit it with smoke (I have smoke on a can) I do get values in Vera under the Variable1 property. No values on the dashboard device itself. I guess some changes are needed for the device file to display the V_VAR1 or we should use something else than V_VAR1.

If you have already updated the sketch for the MQ-2 please let me know where I can get the latest version so I can try it out.

btw, is the MQ-2 supposed to give the value 0 after it is calibrated in clean air? My sensor sends the value 0 all the time unless I hit it with my smoke can.

If you have already updated the sketch for the MQ-2 please let me know where I can get the latest version so I can try it out.

btw, is the MQ-2 supposed to give the value 0 after it is calibrated in clean air? My sensor sends the value 0 all the time unless I hit it with my smoke can.

Yes I am deeply modifying it, and will have a question for @hek : to have something consistant in time, it owuld be better to have the initial calibration stored, either in EEPROM or as a VAR on the server. Could it be possible that I introduce a loop that wait till the var is answered and if not go into calibration ?

I've used your clean air calibration in open air given values of air concentration where appropriate. Around sept 20th I applied this method t omy sketches and I have since sensors that are very much more reactive ! Only 2SH12 has no curve, it is voltage for this (damn) sensor doesn't have a datasheet...

I don't know if this was this predictible...

They are all placed inside a room that I sometime open to clean air. Also there are restarts that calculates again those values where you see it drop maybe, but anyway it will still go to the previous values.

@Yveaux@korttoma
Bummer... this is the same formula when doing the reduction.... one is 1023 the other 1024 the only change.

The RL_VALUE for Davide was 22k, when I mesure the resistance with Analog out with ground, I get 0,996 or 0,999 ohms depending on the sensor. I guess this is the RL_VALUE of the board which is way below the sensor maker recommendation (between 10K and 47K for a MQ135).

Also, I saw that the pot on the board does not change the analog to ground resistance, meaning it is used only for comparison of the digital output....

something to remember: MQ135 was calibrated for 1ppm of CO, not 399ppm of CO2, so the calculated value is very low, a per gas Ro must be calculated (clean air calibration) if several gas on one sensor is required to be displayed.

I'm new here, thanks to this topic very interesting for my personal project: a mobile air quality sensor.
(sorry for my english, i'm french)

Fistly, congrat's @epierre and the other, for having shared all this informations!
(it's a litte funny because we had the same idea in the almost same time)
So after having read the entire subject, here my questions (the number in front is the number post):

_
17 - @epierre, I haven't well understand How you can distinguish individual gas from a sensor who react with several gas.

45 - The "Wunder Weather" list that you talked about, it's a website?

55 - What David did you answer to you about "if he speaks of the organic sensor or the ceramic ones"?
Moreover, what are the organic sensors? Have you example?

55 - What David did you answer to you about "if he speaks of the organic sensor or the ceramic ones"?
Moreover, what are the organic sensors? Have you example?

The organic are the one that have a lifetime of 2 years, calibrated but wery expensive (aroung $150+ apiece), the winseng one for example, big and round.

72- On winsensor.com, an chinese gas sensor producer, the MQ-7 is more powerfull... I don't know who trust, maybe it's not the same?? See the PDF datasheet here.

this is hard to say... the MQ-7 is quite special with a sequence to power it up, and readings every period.

81 - Where did you read that the lastest one don't speak of HCHO anymore?
After some research, I found two, one who speak about HCHO here in english , and the other who don't....but I'm not sure (beacause in chinese) here.

I don't see mention of HCHO (formaldehyde) in the english one (n-Hexane, Benzene, NH3, alcohol, ,smoke, CO. I found one in chinese with the link above but the curve couldn't be exploited. Please remark that Alcohool has not a single formula, but here they show only one curve, not very precise.

Otherwise, for the WSP2110 datasheet, it is here! But chinese too =/

Yes for this one something can be done, but there is no for WSP1110 there is no...

@epierre : after received the PPD42NS, compared to the DSM501A, which one is the best do you think?

Other things, I planned to purchase soon the sensors that I need for my air station.
You made a list on the #1 post, and it's very useful thanks, but now I have to choose between them for each gas targeted (maybe some sensors are still missing on the list below)

Which one appears for you, the better for each gas, with a reasonable price?

Great project!
I hooked up an MQ135 (sensor on a little pcb with (i think) smd resistor 102 (=1K ohm) between gnd and B )
The readings are however all over the place (135ppm to 1332ppm), so i think i need to calibrate. The raw reading is alwas in the range 71-80 (inside).

I know i have to get it outside and the reading should be 392 or 399 ppm but i am unsure what var i should change?
The sketch says mq135_ro (this has to be tuned 10K Ohm) but that does not seem to be used in the calculations?

I tried the sensor outside, but I am getting some different readings: the measured value changes from 59 to 82. The mq135_ro (i suppose that's the suggested ro) from 3081.00 to 81416 (does not go linear with the measured value?
The sensor was heated for more than 24h and then moved outside (started measuring after 5min, in windy conditions)

I take it that you are talking about the Air_Quality sketch right? The problem is that you do not have the device files for this kind of sensor in your Vera MySensor plugin. There is another thread that contains the files, I'll see if I can find it.

@epierre thank you for sharing this code - your work is stellar. I'm working with a team of three other people to build a payload for a near space weather balloon launch in a couple of weeks.

We're using the MQ131 Ozone Gas Sensor and your code has been quite useful to us. One question though, when our data logger reads the sensor we're getting a single number value. We're not exactly sure what that number means. Could you help explain what we're seeing? Are we getting a ppb number? ppm? Or something else altogether?

@jroseastro hello, first of all the MQ series are not so precise as that, use it for a test run, but for serious purpose please consider something better and with calibration.

Ozone is quite chalenging, if you go very high, since the MQ nead heating to work, it will drain fast your batteries.

For any sensor always refer to the datasheet.

MQ131 is given from 5 to 100 ppb (reason you get only a single value) if you use the provided calibration sheet. So the result is the one from the curve. We've had a discussion not yet settled with @hek about units and this is why I've not put it, but maybe I should uniformize everything in ppm since this is the most prevalent value used.

Also the datasheet says you need 6V to heat it, so you cannot heat it from the arduino except with a step up (not that good) or an external power source (best) with a voltage regulator.

The concentration of NH3 is 0.99 ppm
The concentration of CO is 1.20 ppm
The concentration of NO2 is 0.15 ppm
The concentration of C3H8 is 1000.04 ppm
The concentration of C4H10 is 999.98 ppm
The concentration of CH4 is 2991.14 ppm
The concentration of H2 is 1.09 ppm
The concentration of C2H5OH is 1.40 ppm

I think MQ131 need 24 hours preheating time.Because of preheating time it will be costly. and for MiCS 6814 how do you calculate or measured other values of gases?? Because sensor's data sheet it hard to understand

I think MQ131 need 24 hours preheating time.Because of preheating time it will be costly.

no MQ is expected to run on battery for they always need pre-heating before getting a value.

and for MiCS 6814 how do you calculate or measured other values of gases?? Because sensor's data sheet it hard to understand

So fat I only use the provided library. Sensors are said to be factory calibrated, maybe a reason they are so costly. I'm not running it constantly at this time, but I saw no change in the few time I ran it so I'm still expecting to see something.

I've started working with an MQ135 sensor, attached to a board like the disucssion you had from a year ago. I measured some of the resistances between the Aouts and the sensor pins and seems similar with the 1kohm resistance between AO and Gnd, and the pot not changing the output.

I was wondering if anyone managed to calibrate their board using the AO of this board, and if so how? I can't seem to get a good resolution, as it has noise of at least in the 10's of ppm.

I'm considering whether its simpler to by pass the board and its amplifier, and directly hook set up onto the sensor itself with the correct resistors.

I've started working with an MQ135 sensor, attached to a board like the disucssion you had from a year ago. I measured some of the resistances between the Aouts and the sensor pins and seems similar with the 1kohm resistance between AO and Gnd, and the pot not changing the output.

I was wondering if anyone managed to calibrate their board using the AO of this board, and if so how? I can't seem to get a good resolution, as it has noise of at least in the 10's of ppm.

I'm considering whether its simpler to by pass the board and its amplifier, and directly hook set up onto the sensor itself with the correct resistors.

Calibration is not possible as it varies between the same sensors of this construction class. Check datasheet on minimal sensibility also on low and max values.

Also without a gas concentration it is not possible to calibrate it. The best guess is that co2now.org gives you that outside (aka clean air) it is 399 for CO2, but that would be only for CO2 and not the other gases !

Since the board show RL, I took that to calculate Rs. This lets me calculate Ro, thus calibrate it.

Not quite sure where I'm going wrong. I had it working 8 months ago, and came back to it and couldn't figure out how i had it working so well.. I was able to get pretty nice graphs and now its very unstable.

Since the board show RL, I took that to calculate Rs. This lets me calculate Ro, thus calibrate it.

Not quite sure where I'm going wrong. I had it working 8 months ago, and came back to it and couldn't figure out how i had it working so well.. I was able to get pretty nice graphs and now its very unstable.

Adjusting my mq-135 sensor took several atempts as the CO2 value of the atmosphere is not a constant value of 399ppm.
This value is measured in Hawaii ( see http://co2now.org/ ) and is probably significantly lower than at your home. In germany for example you should calibrate your sensor when the wind comes from west over the atlantic which brings fresh air along. See http://www.donnerwetter.de/deutschland/co2.htm

I have a question for the MQ135. Do not always be above 500 ppm, the measured values? I also get values of 0. I suspect that it is due to the conversion. The values vary greatly. Is that normal? I get the values with an ordinary power supply.

I have used the code from epiere. Baking I have not done. I use different power supplies (USB, Samsung and a large controllable power supply). I sometimes feel that contacts do not function properly. But the sensor draws but only about 100 mA = 0.1 A? Then it seems to be on branding. I have three new sensors. Mostly we read that it is only an attempt here is to measure the CO2 content. When I check the values with a measuring instrument with which agree the details here https://olimex.wordpress.com/2015/05/26/experimenting-with-gas-sensors-and-arduino/ Branding should work outdoors? Can you show me a chart or values?

Hi @paqor,
I wrote a little sketch which you could use as a start, it uses the MQ135 library.
I also used a timer library, but this could be replaced by a simple sleep, too.

RZERO should be changed when calibrating the sensor, this can be done at compile-time or during runtime by sending the value to the sensor via the gateway.

Unfortunately I could not test the sketch yet, but it should help you getting started.
If you have a second sensor which provides humidity and temperature then you can also get the corrected ppm from the library,...

In MiCS 2614 or in any gas sensor. what should be the value of R0... Because in datasheet they mentioned that value is measured in ambient condition. Any default value for that??

The datasheed propose the "clean air calibration": "Sensing resistance in air R0 is measured under controlled ambient conditions, i.e. synthetic air at 23 ±5°C and 50 ± 10% RH. Sampling test."
so you should go outside and mesure the defautl R0 value in your environment.

@epierre I am testing a stripped-down version of your code from your AirQuality-MQ135.ino. I stripped it to make it run just stand-alone.
What I don't understand is how to do the calibration. When I run it in outside environment (with 10k resistor), I get these values: