Air Quality Sensor


  • Mod

    @epierre To decorate your codeblock use 4 spaces or one tab character first on each line.

    This forum uses markdown.
    For help: press the little questionmark-icon in the compose window.


  • Mod

    @epierre you say you need some help reading the logarithmic curves, right?
    I copied one curve from the MQ2 datasheet :
    Screenshot_2014-07-26-18-14-19.png

    Along the horizontal axis you see the values 100, 1000 & 10000.
    Between 100 & 1000 each vertical line adds 100, between 1000 & 10000 each vertical line adds 1000.
    On the vertical axis it works just the same: each horizontal line between 0.1 & 1 adds 0.1, between 1 & 10 it adds 1.
    So the first H2 lies at (200,2)


  • Hero Member

    @Yveaux Thanks, but can you confirm the measure that I quoted above, for I don't find them... (LLPG, CO, what they call smoke ???)

    @marceltrapman thanks for the hint... I spent some time trying to find it... I'm more a wikiforumman


  • Hero Member

    another very interresting post on the theory behind:

    ketosense


  • Hero Member

    Ok mesurement understood...

    values must be in logarithmic... sometime they display lg for log, or directly the log calculated value which does not help understand it...

    so for the slope from the values read : (LOG(0,4)-LOG(1))/(LOG(10000)-LOG(1000)) and I agree to the curves.

    Now let's go to the next point: resistive protection.
    My boards (to few exception) are this : http://img.dxcdn.com/productimages/sku_193001_4.jpg

    There are 1K and 10K resistors, plus a variable one.

    From the article I base myself, it says:

    The protection resistor (4.7Kohms) and the adjustable (0-50Kohms) are in serial which forms a load resistor RL (4.7-54.7Kohms). The sensor’s resistance RS and RL forms a voltage divider. The output voltage on the signal pin could be read by Arduino or MCU via ADC.  Given a value of RL , Power Supply Voltage, and output voltage, RS could be derived.  Based on the chart provided in the MQ-2 datasheet, RS in clean air under given temperature and humidity is a constant,which is the “initial” resistance of the sensor named RO. RO of the resistor could be derived from RS. 
    

    I guess it is a different board here, so values must differ. Have you an idea how to mesure this with my multimeter ? else each time the sensor would start, the value would be calculated, clean or not :

    The main job of the calibration is to calculate the RO by sampling and averaging the readings when the module is placed in the clean air. Once the RO is derived, the concentration of target gas could be calculated by using the RS/RO ratio as the input. To achieve more accuracy, a segmented look-up table should be used. However, in the demonstration, a linear formula is used as an approximation to the original curve.

  • Hero Member

    So tonight with these new formulae, I updated my mega sketch to get :

     MQ2    :LPG   :0ppm    CO    :0ppm    SMOKE :0ppm
     MQ6    :LPG   :0ppm    CH4   :0ppm
     MQ131  :CL2   :1ppm    O3    :1ppm
     TGS2600:H2    :0ppm    C2H5OH:0ppm    C4H10 :0ppm
    

    Going through the "clean air calibation" I have:

    float MQResistanceCalculation(int raw_adc)    {
      return ( ((float)RL_VALUE*(1023-raw_adc)/raw_adc));
    }
    

    Here are the readings without:

    MQ2:5.28
    MQ6:36.94
    MQ131:3.61
    TGS2600:0.04
    

    and with all is 0... BTW...

    What do you think of that ? nothing indicated that MQ6 should be so big, and tgs so low... same for MQ131 that should be 100k-200k per datasheet....


  • Mod

    @epierre are you totally sure of the calculation in MQResistanceCalculation? Maybe the evaluation is correct, but I always add some braces to make the evaluation order explicit: first do the substraction, then the float multiplication and the integer division, cast to float, as last.


  • Hero Member

    @Yveaux you mean something like this ?

    return ( (((float)RL_VALUE*(1023.0 - (float) raw_adc)) / (float) raw_adc));
    

    I somehow forked the discussion on arduino.cc and sent an email in parallel do Davide Gironi for I would like to understand his formula as opposed to the curve approach.


  • Hero Member

    This post is deleted!

  • Mod

    @epierre something like that, yes. You could also feed it some artificial values in a debug build and see if the calculated values match your expectations.
    It wouldn't be the first time that some calculations (divisions) are unexpectedly calculated as ints and always return either 0 or 1 instead of the expected fraction...


  • Hero Member

    Hello,

    Having sorted out how to make a power regression, I now have the sames values as Davide Gironi.

    I applied this to MQ2, MQ6, MQ131, MQ135 and TGS2600 with resistance calibration at start.

    MQ2    :LPG   :12ppm    CO    :0ppm    SMOKE :21ppm
    MQ6    :LPG   :3ppm    CH4   :39ppm
    MQ131  :CL2   :2ppm    O3    :3ppm
    TGS2600:H2    :5191ppm    C2H5OH:8825ppm    C4H10 :16954ppm
    MQ135  :CO2    :0ppm    CO    :0ppm    CH3    :0ppm    NH4    :0ppm
    GP2Y1010AU0F Raw Signal Value (0-1023): 19 - Voltage: 0.09 - Dust Density: -84.23
    

    the MQ135 is still doing its first heating period, do not care about its values.

    Clearly the TGS shows abnormal values, I'm quite puzzled by this, using the previous method it was always 0...


  • Mod

    @epierre I'm still a bit wondered by the way in which you present the values.
    I, for instance, have an MQ135. Is "sensitive to noxious gas concentration. MQ135 sensor also sensitive to sulfide, benzene steam, smoke, etc". The logarithmic charts in the datasheet show the sensitivity to the various gases.
    This sensor has a single analog output from which IMHO you cannot determine the fraction of individual gases. Yet you present them as individual values in your measurement data... How can you distinguish?


  • Hero Member

    @Yveaux in fact it is a correlation, if you have a value from the analog, then from the curve you can guess it is one of the group, not one individually... it is the way they are designed...


  • Mod

    @epierre That's exactly my point!


  • Hero Member

    @Yveaux and there's worse : if you don't have the environment to calibrate it with real gas, it is just an indication... that is maybe why some projects that may have taken such sensor may hae a production process issue at the moment... In fact despite my researches, I've never found someone that said it made it to mesure correctly with gas sensors, mostly theory or just analog reading only...

    An example: my MQ135 was silencious, I put its nose in the Aceton bottle:

    Before:
    Q2 :LPG :11ppm CO :0ppm SMOKE :18ppm
    MQ6 :LPG :3ppm CH4 :36ppm
    MQ131 :CL2 :2ppm O3 :3ppm
    TGS2600:H2 :7602ppm C2H5OH:13706ppm C4H10 :26350ppm
    MQ135 :CO2 :0ppm CO :0ppm CH3 :0ppm NH4 :0ppm
    Dust :raw : 18 Voltage: 0.09 - Dust Density: -85.06

    After:
    MQ2 :LPG :208ppm CO :0ppm SMOKE :832ppm
    MQ6 :LPG :44ppm CH4 :172ppm
    MQ131 :CL2 :16ppm O3 :17ppm
    TGS2600:H2 :7774ppm C2H5OH:13818ppm C4H10 :27274ppm
    MQ135 :CO2 :999ppm CO :0ppm CH3 :484ppm NH4 :1904ppm
    Dust :raw : 58 Voltage: 0.28 - Dust Density: -51.86

    The MQ135 has reacted, but all others around...


  • Hero Member

    doing the same on my basic sketch here what I have:

    2014-08-03 11:29:57 3 0 1 24 -28393
    

    looks like my old sketch needs some update...


  • Hero Member

    Doing the same on the basic sketch :

     Vrl / Rs / ratio:4.21 3731.17 0
     CO ppm :inf
    

    Then:

    Vrl / Rs / ratio:4.21 3731.17 0
    CO ppm :inf

  • Hero Member

    and now ethanol/isopropylène (bike chain cleaning product):

    MQ2    :LPG   :247ppm   CO    :0ppm    SMOKE :1053ppm
    MQ6    :LPG   :3527ppm    CH4   :2160ppm
    MQ131  :CL2   :10ppm    O3    :12ppm
    TGS2600:H2    :7891ppm C2H5OH:14279ppm C4H10 :27751ppm
    MQ135  :CO2   :0ppm    CO    :0ppm     CH3   :0ppm    NH4    :0ppm
    Dust   :raw   : 206    Voltage: 1.01 - Dust Density: 71.00

  • Hero Member

    and now eveyone through aceton:

    MQ2    :LPG   :25ppm   CO    :0ppm    SMOKE :48ppm
    MQ6    :LPG   :19677ppm    CH4   :3010ppm
    MQ131  :CL2   :71ppm    O3    :51ppm
    TGS2600:H2    :8448ppm C2H5OH:15007ppm C4H10 :28738ppm
    MQ135  :CO2   :840ppm    CO    :0ppm     CH3   :400ppm    NH4    :1474ppm
    Dust   :raw   : 728    Voltage: 3.55 - Dust Density: 504.30
    

    remark that dust sensor goes up ! and TGS2600 goes down afterward:

    MQ2    :LPG   :8ppm   CO    :0ppm    SMOKE :11ppm
    MQ6    :LPG   :1264ppm    CH4   :1194ppm
    MQ131  :CL2   :27ppm    O3    :24ppm
    TGS2600:H2    :4966ppm C2H5OH:8407ppm C4H10 :16227ppm
    MQ135  :CO2   :840ppm    CO    :0ppm     CH3   :400ppm    NH4    :1474ppm
    Dust   :raw   : 165    Voltage: 0.81 - Dust Density: 36.96

  • Hero Member

    @hek I now have the netatmo CO2 xml and json, they are based on the generic sensor.

    But I don't have mysensors running on my vera...

    I would need from you:

    • the device and variable type
    • an icon, but maybe I can reuse the other one

    maybe
    CO2 = {22, "urn:schemas-micasaverde-com:device:CO2Sensor:1", "D_CO2Sensor.xml", "CO2 "}
    CO2 = {36, "urn:micasaverde-com:serviceId:CO2Sensor", "Concentration", "396" },

    S_CO2Sensor.json D_CO2Sensor.xml D_CO2Sensor.json

    P.S. there's the icon from Nest plugin too: http://cocu.la/vera/nest/nest_co.png


  • Hero Member

    About initial calibration, just a warning from this graph:

    chart.png

    you can see high levels around july 21 then dropping in august... the sensor has been restarted... that is what the call clean air...

    this automatic reading at the start should be stored in the sketch and not reclaculated at each reboot or you would loose all reference on your data...


  • Hero Member

    This post is deleted!

  • Hero Member

    This post is deleted!

  • Mod

    @epierre did you just post the same reply 3 times or is the forum software showing yet another bug?


  • Hero Member

    @Yveaux don't know, I did post once...


  • Hero Member

    I wanted to get acquainted with the MQ2 AirQuality Sensor so I took a look at the sketch from github.
    One thing I noticed was that there is some sleep-time defined, is this just to make the sensor report the value every 30 seconds?
    I guess it is not for saving power so you can run it on batteries because my understanding is that it needs to be hot in order to function correctly and that will drain the battery fast.

    Does not look like the calibration during setup takes in account the preheating time either, maybe it is a good idea to add a delay before the calibration so the sensor gets hot enough.

    Please correct me if I'm wrong.


  • Hero Member

    @hek Here is a first list from the most commons:

    • Carbon Monoxide – CO
    • Carbon Dioxide – CO2
    • Oxygen – O2
    • Methane – CH4
    • Hydrogen – H2
    • Ammonia – NH3
    • Isobutane – C4H10
    • Ethanol – CH3CH2OH (aka C2H5OH or C2H60)
    • Toluene – C6H5CH3
    • Hydrogen Sulfide – H2S
    • Nitrogen Dioxide – NO2
    • Ozone – O3
    • Hydrocarbons – VOC
    • Chlorine CL2
    • Ammonium NH4
    • Ethanol CO2H50H
    • Methyl CH3
    • Acetone CH3_2CO
    • LPG (both C3H8 C4H10)

  • Hero Member

    @korttoma said:

    Does not look like the calibration during setup takes in account the preheating time either, maybe it is a good idea to add a delay before the calibration so the sensor gets hot enough.

    Please correct me if I'm wrong.

    I see your point, but from experience I don't see a difference on heating... I should have a closer look. This one does not need a special pre-heating as some other (MQ-7).

    Clearly this cannot run on battery on MQ/TGS/MICS series, so surely removing the sleep and adding a wait would do the trick the same way.

    If you want to play and see something, the MQ135 is much better for it reacts to CO2, so having someone in a room or not you could see it easily changing.

    A current weakness on the sketches is to take into accound humidity and temperature to correct the value, that will come too.


  • Hero Member

    I was looking for some other gas sensor, but these have no shield ready to connect to arduino :

    Sensor	     Operating Voltage  	Heater Power
    MiCS-2710 (NO2)	  2.5 V	           43 mW
    MiCS-5525 (CO)	   5.0 V	           76 mW
    

    do I need a dedicated 2.5 V linear regulator such as Microchip TC1071VCT713 ?


  • Hero Member

    This post is deleted!

  • Hero Member

    This post is deleted!

  • Hero Member

    @hek about initial calibration, how would I do check if there is a value in the eeprom or not, and if not run an initial calibration ?


  • Admin

    @epierre

    Unwritten eeprom has the value 0xff.



  • Hi,
    First of al I'm a novice in all of this. I can read some code but the whole arduino thing is new to me.

    I tried to get the MQ135 working on my uno with tearing apart the : https://github.com/empierre/arduino/blob/master/1.3/MQ135dgi.ino.
    I tried to pull out the bits and parts to get a accurate reading on my serial monitor.

    It sometimes read 1 or 2, but most of the time it is 0.
    Can it have something to do with it being mounted on its own PCB? (I ordered the one suggested in the store..)
    Can someone help me out?

    Groetjes Mark


  • Hero Member

    @Omemanti hello have you plugged it on the right pins, this is an analogic sensor to be plugged on A0, with 5V and GND pins. Don't wire the digital one, useless...

    My minimal value is 53.. so not 0 or 1 hwich looks more like the digital output 😉



  • should be alright right?

    mq135ex.jpg


  • Hero Member

    @Omemanti cabling is correct


  • Hero Member

    Hi,
    Where can I find AirQuality1.xml?? (or all files related to this device if there are others then the .xml)

    01 09/03/14 13:46:53.685 ctrl_chr[31;1mDevice_LuaUPnP::LoadDeviceDoc can't load /etc/cmh-lu//D_AirQuality1.xmlctrl_chr[0m <0x2acc9000>
    02 09/03/14 13:46:53.686 ctrl_chr[33;1mJobHandler_LuaUPnP::m_sMissingFile_set /etc/cmh-lu//D_AirQuality1.xmlctrl_chr[0m <0x2acc9000>

    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.

    Help!!


  • Admin

    @korttoma

    Unfortunately no one has created it 😞


  • Hero Member

    @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...


  • Hero Member

    I made a template but I'm unable to test it...


  • Hero Member

    @hek here is an updated list from the Wunder Weather list of reportable gases:

    Carbon Monoxide – CO
    Carbon Dioxide – CO2
    Oxygen – O2
    Methane – CH4
    Hydrogen – H2
    Ammonia – NH3
    Isobutane – C4H10
    Ethanol – CH3CH2OH (aka C2H5OH or C2H60)
    Toluene – C6H5CH3
    Hydrogen Sulfide – H2S
    Nitrogen Dioxide – NO2
    Ozone – O3
    Hydrocarbons – VOC
    Chlorine CL2
    Ammonium NH4
    Ethanol CO2H50H
    Methyl CH3
    Acetone CH3_2CO
    LPG (both C3H8 C4H10)

    • NO - nitric oxide
    • NOX - nitrogen oxides
    • NO3 ion (nitrate, not adjusted for ammonium ion) UG/M3
    • SO4 ion, sulfate, not adjusted for ammonium ion, UG/M3
    • SO2 sulfur dioxide, ppb
    • EC (elemental carbon) – PM2.5 UG/M3
    • OC (organic carbon, not adjusted for oxygen and hydrogen) – PM2.5 UG/M3
    • BC (black carbon at 880 nm) UG/M3
    • UV-AETH (second channel of Aethalometer at 370 nm) UG/M3
    • PM2.5 mass - UG/M3
    • PM10 mass - PM10 mass

  • Admin

    Thanks!

    Still thinking about you gas_type suggestion. It would introduce another level of device types. Hmm..


  • Hero Member

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


  • Hero Member

    @Yveaux I know you are strong at finding datasheet... can you find one for me ? I can't find the 2SH12 sensor altgough I've asked for it to all suppliers on aliexpress...

    Same for theWSP1110


  • Mod

    @epierre Couldn't find it either, sorry...
    I wouldn't buy a $52,- component without a datasheet, if I were you...


  • Hero Member

    @Yveaux When I asked for the WSP110 they sent me only this (not the same for this one is HCHO and well documented...) :

    HTB1WamGGXXXXXXVXFXXq6xXFXXXS.jpg


  • Admin

    @epierre

    I wonder what the green curve represents 😕


  • Hero Member

    @hek that should be the more sensitive, and since it is given mostly for CHCO I guess this is it... (Formaldehyde)


  • Hero Member

    @hek 甲醛 is formaldehyde, given by google translate so I'm right !


  • Admin

    @epierre

    Haha 👍


  • Hero Member

    Davide answered me, lot of things to read but a warning:

    Anyway, for consistent CO2 investigaion, you HAVE to chose a NDIR sensor, those chemical sensor can not be used. They decay in a few year, and they differs a little one from each other.
    

    I've asked him back for precision if he speaks of the organic sensor or the ceramic ones (like MQ...).

    For the CO2, it is MH-Z14 which is $66+ priced.


  • Admin

    @epierre said:

    MH-Z14

    Like this little puppy?


  • Hero Member

    @hek exact !


  • Hero Member

    @epierre said:

    @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?

    Sorry for all the questions 😉


  • Hero Member

    @korttoma said:

    Thanks, found the device files and got the device included again.

    So you confirm they can be used as is ?

    @korttoma said:

    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.

    @korttoma said:

    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...

    @korttoma said:

    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.

    @korttoma said:

    Sorry for all the questions

    good questions are always useful, especially when they meet my current subject of interrest 😉


  • Hero Member

    @epierre said:

    @korttoma said:

    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:

    1. 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?
    2. define RL_VALUE (5)
      -- does this refer to the size of the protection resistor between A0 and ground?
    3. define RO_CLEAN_AIR_FACTOR (9.83)
      -- does this value need to change at all?
    4. 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?

    Sorry for all the questions, I appreciate any input! Thanks!


  • Hero Member

    @pbo

    1- see http://www.electronicaestudio.com/docs/SHT-114.pdf Fig 2 for wiring, the adjustable resistance is with ground and the sensor.

    2- yes

    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Ω



  • @epierre

    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?

    Sorry for all the questions, it's a bit complicated. Thanks again!


  • Hero Member

    @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.


  • Hero Member

    I tried to analyze what is on the small ciscuitboar for my MQ-2 sensor an here is what I think it contains:
    upload-7d5906ec-43dc-4e10-a66f-65c84d5026cc

    So adding the 10K between AOUT and GND is pointless. So what now? Can I use it as is and just use the 1K value for RL in the sketch or is it recommended to change the 1K to something else (10K)??


  • Hero Member

    @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..


  • Hero Member

    @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...


  • Hero Member

    @epierre

    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 😉


  • Hero Member

    Now changed my sensor according to this (disconnected the OP related to DOUT) :
    upload-94e081f9-006e-4d91-b736-3f82ef8e119b

    Please confirm that this is how it is preferred to be connected.


  • Hero Member

    Hello,

    I guess here you have the same that the datasheet, so I assume it is ok 😉

    I've been working to port sketches to a Spark Core with good results, the 12 bits ADC gives more precise values, at least the MQ135 is now very sensitive.

    I am also correcting errors in the sketches I have produced.


  • Hero Member

    Hello,

    A good article on the comparison of 3 same MQ-7 sensors

    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.

  • Hero Member

    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.


  • Hero Member

    @korttoma said:

    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 ?

    @korttoma the best sketch so far is the following, to be scaled down to one sensor, remove specific Mega initialization. I will make a simpler one based on this soon, as I have already done it for the Spark core.
    https://github.com/empierre/arduino/blob/master/MQv01dgi_1_4.ino


  • Admin

    @epierre

    The best solution (and most simple) is to keep calibration data in EEPROM.


  • Hero Member

    Now some questions I have currently:

    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.

    MQ135 in CO2:
    MQ135-CO2.png
    MQ2 in Smoke:
    MQ2-Smoke.png
    2SH12 in SO2 in voltage:
    2SH12-SO2.png
    MQ6 in O3:
    MQ6-O3.png


  • Hero Member

    @korttoma I have found a sketch that may interrest you about the gas sensors boards:

    http://www.parallax.com/sites/default/files/downloads/27983-Gas-Sensor-Board-A-Schematic.pdf

    Their document speaks also about calibrating some gases:
    http://www.parallax.com/sites/default/files/downloads/27983-Gas-Sensor-Board-Guide-v1.0.pdf


  • Hero Member

    @Yveaux I have doubts about calculing the resistance, for it is depending on the steps, either 1024 or 4096, and/or the voltage either 5V or 3.3V.

    I started with this formulae:

    return ( ((float)RL_VALUE*(1023-raw_adc)/raw_adc));
    

    But saw Davide Gironi using this one:

    return  (long)((long)(1024*(long)RL_VALUE)/raw_adc-(long)RL_VALUE);
    

    RL_VALUE=22000


  • Hero Member

    @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....

    Am I correct in mesuring this ?


  • Mod

    @epierre said:

    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....

    That seems to match the schematic above where the pot connects to + of the lm393


  • Hero Member

    @Yveaux Doing so, I have used a RL_VALUE for each board I mesured, one went to 5MOhms...

    MQ2:-8.85
    MQ6:0.00
    MQ131:0.00
    TGS2600:0.00
    MQ135:0.00
    2SH12:-155004.00
    TGZS2602:0.00
    

    Something to be noted: same boards have the same resistance, whatever the sensor maker recommendation, this is a pity...

    The output I have:

    MQ2    :LPG   :7ppm    CO    :0ppm    SMOKE :10ppm
    MQ6    :LPG   :0ppm    CH4   :0ppm
    MQ131  :CL2   :0ppm    O3    :0ppm
    TGS2600:H2    :0ppm    C2H5OH:0ppm C4H10 :0ppm
    MQ135  :CO2   :0ppm    CO    :0ppm     CH3   :0ppm    NH4    :0ppm
    2SH12  :SO2   :-154588.20 raw 
    TGS2602:C7H8  :0ppm
    Dust   :raw   : 0    Voltage: 0.00 - Dust Density: -0.10
    

    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.


  • Hero Member

    Some interresting points from another discussion on the MQ138 that is given for HCHO.

    Historically a datasheet said so, but it is impossible to read the datasheet curves:
    http://china-total.com/Product/meter/gas-sensor/MQ138.pdf

    The latest ones do not speak of HCHO any more.

    An available alternative: grove is a wsp2110 and datasheet can be found.
    http://www.seeedstudio.com/wiki/Grove_-_HCHO_Sensor



  • Hello all,

    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?

    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.

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

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

    Regards,
    Alex.


  • Hero Member

    Hello,

    This is a short post, half has been lost in a forum crash, I hope the best remains 😉

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

    You cannot as I showed below with the broken perfume bottle, you can guess there is one, but not which one.

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

    This is wunderground.com

    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...



  • Ok! Thanks.

    And what about the ceramic sensors (like MQ serie). How long can we trust them?


  • Hero Member

    @alex said:

    Ok! Thanks.
    And what about the ceramic sensors (like MQ serie). How long can we trust them?

    a bit longer but they vary in time as Davide made the remark, so calibration is not one time in its life...



  • Hello

    @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?

    O3		    MQ131   MICS-2610    Mics-2614
    NO2 	      MiCS-2710    MiCS-2714
    NO            ? 
    PM10 PM2.5    PPD42NS    SamYoung DSM501
    Benzene	   MQ135			
    CO  	      MQ307A   MQ309A   AQ-7   MiCS-5525   TGS2442
    So2 	      MQ136
    COV       	MQ135  TGS2602
    CO2 	      MQ135

  • Hero Member

    @alex said:

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

    I currently have only the DSL501A working, many issues with the dead Shinyei (still in dispute escalade) and getting one from another seller takes so much time...

    Which one appears for you, the better for each gas, with a reasonable price?
    O3 MQ131 MICS-2610 Mics-2614
    NO2 MiCS-2710 MiCS-2714
    NO ?
    PM10 PM2.5 PPD42NS SamYoung DSM501
    Benzene MQ135
    CO MQ307A MQ309A AQ-7 MiCS-5525 TGS2442
    So2 MQ136
    COV MQ135 TGS2602
    CO2 MQ135

    The price is low, but so is the result. Only the CO-MH-Z14 is calibrated. For all the others, there is the calibration issue.

    See the sketch for a lit of known/tested sensors (some I don't have but a frien asked me for the curves so I added it to the Mega sketch)
    https://github.com/empierre/arduino/blob/master/AirQuality-Multiple_Gas_Sensor1_4.ino

    • The MiCS are problematic to find in Europe (!) so I have only one that I have not yet tested.
    • The Figaro have been tested, but it is hard to know how to really test them on some gases...
    • The MQxx:
      • MQ2: good result on smoke
      • MQ135 good result on CO2
        The others I'm not yet able to give any opinion.


  • 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'm using the standard Smoke sketch from Mysensor library and it seem to be crashing MySensor plugin on Vera edge. Below is a snapshot of the problem. Any ideas?

    Screen Shot 2015-05-07 at 8.13.01 AM.png


  • Hero Member

    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.

    Edit: Found the thread -> http://forum.mysensors.org/topic/661/assistance-needed-completing-gas-air-quality-sensor



  • @korttoma

    I'm going to try experiment tomorrow... Thank you!



  • @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?


  • Hero Member

    @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.


  • Hero Member

    I'm now testing the MICS-6814 (3 sensors in one) given for :
    Carbon monoxide CO 1 -1000ppm
    **Nitrogen dioxide NO2 0.05 –10ppm **
    Ethanol C2H5OH 10 –500ppm
    Hydrogen H2 1 –1000ppm
    Ammonia NH3 1 –500ppm
    Methane CH4 >1000ppm
    Propane C3H8 >1000ppm
    Iso-butane C4H10 >1000ppm

    Datasheet maionly speaks on CO, NO2 and NH3:
    http://www.seeedstudio.com/wiki/images/1/10/MiCS-6814_Datasheet.pdf

    Here is are scripts:
    http://www.seeedstudio.com/wiki/Grove_-_Multichannel_Gas_Sensor

    http://www.seeedstudio.com/wiki/images/1/10/MiCS-6814_Datasheet.pdf

    Some readings:

    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 guess I'll make a script soon...



  • 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


  • Hero Member

    @bhavika said:

    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.



  • @epierre Hi...it is ameasing your work 😄

    I am wondering about Mq-135. We have troubles with reading differents gases.
    From the datasheet we read the slopes
    Gas X" X0" "Rs/R0 "Rs/R0 pendiente (log y- log y0)/(log x-log x0)"
    Air 200 10 3.6 3.6 0.00000
    co 200 10 1.3 2.9 -0.26783
    nh4 200 10 0.79 2.7 -0.41024
    c02 200 10 0.8 2.4 -0.36673
    3/4/ 200 10 0.72 1.9 -0.32391
    1/4/ 200 10 0.64 1.5 -0.28432
    +- 200 10 0.59 1.4 -0.28845

    the data are in the next worksheet https://docs.google.com/spreadsheets/d/18Z6XyxwXVsWdMIk9vbUuCucaLJDdmR0QUFSTYG79ftw/edit?usp=sharing

    ¿may you share with us your code for this sensor in order to see your slopes and Rs/R0 values ?
    ¿do you know the meaning of the name of gases with 3/4 or 1/4 or +-

    thank you in advance


  • Hero Member

    @haro

    based on a datasheet, this one:
    https://drive.google.com/file/d/0B8OvrwVDp8fCcWpHSjZNVzB1TjQ/view

    I apply a power regression (tool: http://www.xuru.org/rt/PowR.as ) on the following points (I've not marked down values but theses are close match):

    0.8 200 
    1 100
    2.3 10
    

    Result: y = 103.6748512 x-2.81699418
    Residual Sum of Squares: rss = 45.01031346

     ¿do you know the meaning of the name of gases with 3/4 or 1/4 or +-
    

    looks like you had a chinese datasheet 😉 just remember those are correlated gases based on particle size for those captors, so it is not very accurate...

    You can find many more sensors hare : https://github.com/empierre/arduino/blob/master/AirQuality-Multiple_Gas_Sensor1_4.ino or simply in https://github.com/empierre/arduino/blob/master/



  • @epierre
    Hi, May be I do not explain my point correctly (or maybe I misundertood ), let me try again.
    We adopt a code, which is the next. The blue lines are the points (for each gas we need two points) that we need.
    https://docs.google.com/document/d/1CevnhBLL9uoyZ31kkrMn-SXeOF_4e9YFGmchj46pGPY/edit?usp=sharing

    Specifically we read from the datasheet the pairs of points for CO
    point1 (lg200 , lg1.3)
    Point2 (lg10, lg2.9)
    then, we construct the data format:{ x, y, slope};
    COCurve[3] = {1.0,0.462,-0.268};

    We are wondering about the pair of points for the others gases or the { x, y, slope} data for them, could you share them?.

    and the other hand, the name of gases with 3/4 or 1/4 or +- appears as well in your datasheet (figure 3)... do you know why?

    thank you so much


  • Hero Member

    I prefer the power regression than the curves.

    From your datapoints :
    1.3 200
    2.9 10

    I find:
    y = 532.6744764 x-3.73371402
    rss=0

    I don't remember where I found the datasheet with the chinese names that I translated through google.



  • @epierre Now I see your point of view and of course it is better way to reduce the error.

    in the other hand, I found the datasheet in chinese an then a friend translate it.
    the meaning of the name of gases is for 3/4 (Alcohol), 1/4 (Tolueno) or +- (acetona)

    Thank you so much.



  • Hi,

    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.


  • Hero Member

    @Yuki-M said:

    Hi,

    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 !



Suggested Topics

10
Online

11.4k
Users

11.1k
Topics

112.7k
Posts