Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Hardware
  3. Air Quality Sensor

Air Quality Sensor

Scheduled Pinned Locked Moved Hardware
calibrationaqigas sensorhchoair quality
270 Posts 46 Posters 308.8k Views 35 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • tantt2810T Offline
    tantt2810T Offline
    tantt2810
    wrote on last edited by
    #145

    Hello,
    I don't know how to calculate 3 numbers of LPGCurve[]. Can you explain clearly for me? Thank you so much !!!

    0_1456336543192_Capture.PNG

    1 Reply Last reply
    0
    • epierreE Offline
      epierreE Offline
      epierre
      Hero Member
      wrote on last edited by
      #146

      @tantt2810 as explained above, if the datasheet has a logarithmic scale, you can use the power regression to approximate the curve. One tool for example to do this calculus:http://www.xuru.org/rt/powr.asp

      for a sensor discussed above I read this on the datasheet:
      H2
      1.3 50
      0.8 100
      0.28 400
      0.16 1000
      0.05 4000

      The xuru website gives me this:

      y = 73.59123879 x-1.355617483
      Residual Sum of Squares: rss = 87393.44418

      and thus I have::
      H2Curve[3] = {73.5912, -1.355617};

      z-wave - Vera -> Domoticz
      rfx - Domoticz <- MyDomoAtHome <- Imperihome
      mysensors -> mysensors-gw -> Domoticz

      tantt2810T 1 Reply Last reply
      0
      • epierreE epierre

        @tantt2810 as explained above, if the datasheet has a logarithmic scale, you can use the power regression to approximate the curve. One tool for example to do this calculus:http://www.xuru.org/rt/powr.asp

        for a sensor discussed above I read this on the datasheet:
        H2
        1.3 50
        0.8 100
        0.28 400
        0.16 1000
        0.05 4000

        The xuru website gives me this:

        y = 73.59123879 x-1.355617483
        Residual Sum of Squares: rss = 87393.44418

        and thus I have::
        H2Curve[3] = {73.5912, -1.355617};

        tantt2810T Offline
        tantt2810T Offline
        tantt2810
        wrote on last edited by
        #147

        @epierre Thank you so much !!!
        Have a nice day =)) !!!

        1 Reply Last reply
        0
        • epierreE epierre

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

          jenbakerJ Offline
          jenbakerJ Offline
          jenbaker
          wrote on last edited by
          #148

          @epierre

          hi

          i am new here.

          sorry i am a little confused by with these new formulate.

          is it the key for module?

          epierreE 1 Reply Last reply
          0
          • tantt2810T Offline
            tantt2810T Offline
            tantt2810
            wrote on last edited by
            #149

            Hello,
            I'm don't understand the recipe below. Why RL_Value(Load Resistance)(1023-raw_adc)/raw_adc)? Can you explain for me?
            Thank you so much !!!
            /
            ***************** MQResistanceCalculation ****************************************
            Input: raw_adc - raw value read from adc, which represents the voltage
            Output: the calculated sensor resistance
            Remarks: The sensor and the load resistor forms a voltage divider. Given the voltage
            across the load resistor and its resistance, the resistance of the sensor
            could be derived.
            ***********************************************************************************/
            float MQ2::MQResistanceCalculation(int raw_adc)
            {
            return ( ((float)RL_VALUE
            (1023-raw_adc)/raw_adc));
            }

            epierreE 1 Reply Last reply
            0
            • jenbakerJ jenbaker

              @epierre

              hi

              i am new here.

              sorry i am a little confused by with these new formulate.

              is it the key for module?

              epierreE Offline
              epierreE Offline
              epierre
              Hero Member
              wrote on last edited by
              #150

              @jenbaker said:

              sorry i am a little confused by with these new formulate.

              is it the key for module?

              if you have a module the datasheet gives you the values, yes. Remember this is their """""generic"""" calibration, in fact they all copy the other so don't expect your MQ** would follow this by the letter...

              z-wave - Vera -> Domoticz
              rfx - Domoticz <- MyDomoAtHome <- Imperihome
              mysensors -> mysensors-gw -> Domoticz

              1 Reply Last reply
              0
              • tantt2810T tantt2810

                Hello,
                I'm don't understand the recipe below. Why RL_Value(Load Resistance)(1023-raw_adc)/raw_adc)? Can you explain for me?
                Thank you so much !!!
                /
                ***************** MQResistanceCalculation ****************************************
                Input: raw_adc - raw value read from adc, which represents the voltage
                Output: the calculated sensor resistance
                Remarks: The sensor and the load resistor forms a voltage divider. Given the voltage
                across the load resistor and its resistance, the resistance of the sensor
                could be derived.
                ***********************************************************************************/
                float MQ2::MQResistanceCalculation(int raw_adc)
                {
                return ( ((float)RL_VALUE
                (1023-raw_adc)/raw_adc));
                }

                epierreE Offline
                epierreE Offline
                epierre
                Hero Member
                wrote on last edited by
                #151

                @tantt2810 said:

                Hello,
                I'm don't understand the recipe below. Why RL_Value(Load Resistance)(1023-raw_adc)/raw_adc)? Can you explain for me?
                Thank you so much !!!
                Input: raw_adc - raw value read from adc, which represents the voltage
                Output: the calculated sensor resistance
                Remarks: The sensor and the load resistor forms a voltage divider. Given the voltage
                across the load resistor and its resistance, the resistance of the sensor
                could be derived.
                float MQ2::MQResistanceCalculation(int raw_adc)
                RL_VALUE
                (1023-raw_adc)/raw_adc));

                in fact it is above described, you have a voltage, you want a resistance.
                https://learn.sparkfun.com/tutorials/voltage-dividers

                datasheet needs a value which is the Rs/Ro (called here RL) where
                Ro: sensor resistance at 100ppm of NH3 in the clean air.
                Rs:sensor resistance at various concentrations of gases

                here the formula is a simplification of this:

                float Vrl = val * ( 5.00 / 1024.0 ); // V
                float Rs = 20000 * ( 5.00 - Vrl) / Vrl ; // Ohm
                int ratio = Rs/Ro;
                ppm = 37143 * pow (ratio, -3.178);

                z-wave - Vera -> Domoticz
                rfx - Domoticz <- MyDomoAtHome <- Imperihome
                mysensors -> mysensors-gw -> Domoticz

                tantt2810T VirV 2 Replies Last reply
                1
                • epierreE epierre

                  @tantt2810 said:

                  Hello,
                  I'm don't understand the recipe below. Why RL_Value(Load Resistance)(1023-raw_adc)/raw_adc)? Can you explain for me?
                  Thank you so much !!!
                  Input: raw_adc - raw value read from adc, which represents the voltage
                  Output: the calculated sensor resistance
                  Remarks: The sensor and the load resistor forms a voltage divider. Given the voltage
                  across the load resistor and its resistance, the resistance of the sensor
                  could be derived.
                  float MQ2::MQResistanceCalculation(int raw_adc)
                  RL_VALUE
                  (1023-raw_adc)/raw_adc));

                  in fact it is above described, you have a voltage, you want a resistance.
                  https://learn.sparkfun.com/tutorials/voltage-dividers

                  datasheet needs a value which is the Rs/Ro (called here RL) where
                  Ro: sensor resistance at 100ppm of NH3 in the clean air.
                  Rs:sensor resistance at various concentrations of gases

                  here the formula is a simplification of this:

                  float Vrl = val * ( 5.00 / 1024.0 ); // V
                  float Rs = 20000 * ( 5.00 - Vrl) / Vrl ; // Ohm
                  int ratio = Rs/Ro;
                  ppm = 37143 * pow (ratio, -3.178);

                  tantt2810T Offline
                  tantt2810T Offline
                  tantt2810
                  wrote on last edited by
                  #152

                  @epierre Hi you,
                  I think the Rs/Ro is not RL. In the datasheet RL=5kOhm. As I know it is a resistance on board Arduino, and we set it 5kOhm. Is it right? I also don't know why we set it equal 5kOhm. =))
                  And why 20000 is in "float Rs = 20000 * ( 5.00 - Vrl) / Vrl ; // Ohm" ?
                  Please help me clearly. Thank you so much !!!

                  1 Reply Last reply
                  0
                  • tantt2810T Offline
                    tantt2810T Offline
                    tantt2810
                    wrote on last edited by
                    #153

                    Hello,
                    I have read the sensitivity characteristics curve in datasheet of MQ135 and I don't know AL R, 3/4, 1/4* and +- mean? Can you help me, please !!!
                    NH4 represent for NH3, doesn't it ?
                    Thank you so much !!!

                    1 Reply Last reply
                    0
                    • tantt2810T Offline
                      tantt2810T Offline
                      tantt2810
                      wrote on last edited by
                      #154

                      Hi everyone,
                      I have an CO2 MG811 sensor. I don't know where tcm pin connect with ?
                      Please help me. Thank you so much !!!!
                      0_1457101257425_F08406-CO2-Carbon-Dioxide-Sensor-Module-font-b-MG811-b-font-Voltage-0-2V-Voltage-Output.jpg

                      epierreE 1 Reply Last reply
                      0
                      • TFPOK1T Offline
                        TFPOK1T Offline
                        TFPOK1
                        wrote on last edited by
                        #155

                        Hello, I'm working with an MQ-136 sensor, and am interested in measuring H2S and/or SO2 concentrations. I've got a simple sketch written which gives me a fairly consistent value on the serial monitor, but I've tried to run the multiple gas sensor sketch both complete and I also tried picking apart the sketch just to include MQ-136 related variables and algorithms, but I can't get it to work. It's showing too many errors to list here. Does anyone have simple conversions from the serial outputs to usable values for various gases that this sensor can measure?

                        1 Reply Last reply
                        0
                        • Joel PérezJ Offline
                          Joel PérezJ Offline
                          Joel Pérez
                          wrote on last edited by
                          #156

                          hello, how i read co2 ppm with my mq135?
                          helpme please

                          1 Reply Last reply
                          0
                          • tantt2810T tantt2810

                            Hi everyone,
                            I have an CO2 MG811 sensor. I don't know where tcm pin connect with ?
                            Please help me. Thank you so much !!!!
                            0_1457101257425_F08406-CO2-Carbon-Dioxide-Sensor-Module-font-b-MG811-b-font-Voltage-0-2V-Voltage-Output.jpg

                            epierreE Offline
                            epierreE Offline
                            epierre
                            Hero Member
                            wrote on last edited by
                            #157

                            @tantt2810 said:

                            Hi everyone,
                            I have an CO2 MG811 sensor. I don't know where tcm pin connect with ?
                            Please help me. Thank you so much !!!!

                            this is an analogic sensor, so VCC/Gnd to power it, and readings on analogic Aout

                            z-wave - Vera -> Domoticz
                            rfx - Domoticz <- MyDomoAtHome <- Imperihome
                            mysensors -> mysensors-gw -> Domoticz

                            tantt2810T 1 Reply Last reply
                            0
                            • epierreE Offline
                              epierreE Offline
                              epierre
                              Hero Member
                              wrote on last edited by
                              #158

                              @tantt2810 sorry for not being more responsive, I left MQ/TGS behind me but I've not kept all my notes on mesuring this and that, that would require me to search for it again. But I appreciate if you can spot me some float/type error conversion in sketches !

                              z-wave - Vera -> Domoticz
                              rfx - Domoticz <- MyDomoAtHome <- Imperihome
                              mysensors -> mysensors-gw -> Domoticz

                              1 Reply Last reply
                              0
                              • epierreE Offline
                                epierreE Offline
                                epierre
                                Hero Member
                                wrote on last edited by
                                #159

                                I was a bit disappointed when a project I contributed to on Kickstarter showed the inside of their boxes, I wonder how they will manage to satisfy customers with calibration... or their home made index as netatmo did
                                0_1457255421408_sensly.png

                                z-wave - Vera -> Domoticz
                                rfx - Domoticz <- MyDomoAtHome <- Imperihome
                                mysensors -> mysensors-gw -> Domoticz

                                1 Reply Last reply
                                0
                                • M Offline
                                  M Offline
                                  moskovskiy82
                                  wrote on last edited by
                                  #160

                                  Used the air quality script for MQ7 but throwed out all the conversions and calibrations. Just reading the plain input from the analogue pin.
                                  I targeted this as a smoke detector but it seems this sensor highly depends on the humidity of the surrounding air. Are there any existing formulas to correct for the humidity of the surounding air?

                                  And on one sensor i have some irratical data as shown below (blue). I wonder if it's a power supply (black and green is DHT) or a broken sensor?
                                  alt text

                                  epierreE 1 Reply Last reply
                                  0
                                  • M moskovskiy82

                                    Used the air quality script for MQ7 but throwed out all the conversions and calibrations. Just reading the plain input from the analogue pin.
                                    I targeted this as a smoke detector but it seems this sensor highly depends on the humidity of the surrounding air. Are there any existing formulas to correct for the humidity of the surounding air?

                                    And on one sensor i have some irratical data as shown below (blue). I wonder if it's a power supply (black and green is DHT) or a broken sensor?
                                    alt text

                                    epierreE Offline
                                    epierreE Offline
                                    epierre
                                    Hero Member
                                    wrote on last edited by
                                    #161

                                    @moskovskiy82 well looks like a strange sensor... try averaging several samples/// always remember to have it running several days before measuring for there are chemical left from china factories...

                                    z-wave - Vera -> Domoticz
                                    rfx - Domoticz <- MyDomoAtHome <- Imperihome
                                    mysensors -> mysensors-gw -> Domoticz

                                    1 Reply Last reply
                                    0
                                    • wreinerW Offline
                                      wreinerW Offline
                                      wreiner
                                      wrote on last edited by mfalkvidd
                                      #162

                                      Hey all,

                                      I've got a question regarding the calibration function in https://github.com/empierre/arduino/blob/master/AirQuality-Multiple_Gas_Sensor1_4.ino :

                                      $ grep MQCalibr *
                                      AirQuality-Multiple_Gas_Sensor1_4.ino:  Ro0 = MQCalibration(MQ2_SENSOR,10,RL0,SmokeCurve);
                                      AirQuality-Multiple_Gas_Sensor1_4.ino:  Ro1 = MQCalibration(MQ6_SENSOR,10,RL1,LPGCurve);
                                      AirQuality-Multiple_Gas_Sensor1_4.ino:  Ro2 = MQCalibration(MQ131_SENSOR,10,RL2,O3Curve);
                                      AirQuality-Multiple_Gas_Sensor1_4.ino:  Ro3 = MQCalibration(TGS2600_SENSOR,10,RL3,C2H5OH_terCurve);
                                      AirQuality-Multiple_Gas_Sensor1_4.ino:  Ro4 = MQCalibration(MQ135_SENSOR,10,RL4,CO_secCurve);
                                      AirQuality-Multiple_Gas_Sensor1_4.ino:  Ro6 = MQCalibration(TGS2602_SENSOR,1,RL6,C7H8Curve);
                                      ....
                                      AirQuality-Multiple_Gas_Sensor1_4.ino:float MQCalibration(int mq_pin, double ppm, double rl_value,float *pcurve )
                                      

                                      Th function MQCalibration should calibrate the sensor in clean air, the calibration function uses the PPM concentration of the gas in a clean air environment.
                                      You already use the appropriate value for i.e. CO2 (around 399 PPM) in the MQ135 sketch - but why are you using those obscure values in the calibration (1, 10) here?

                                      Thanks in advance!

                                      epierreE 1 Reply Last reply
                                      0
                                      • wreinerW wreiner

                                        Hey all,

                                        I've got a question regarding the calibration function in https://github.com/empierre/arduino/blob/master/AirQuality-Multiple_Gas_Sensor1_4.ino :

                                        $ grep MQCalibr *
                                        AirQuality-Multiple_Gas_Sensor1_4.ino:  Ro0 = MQCalibration(MQ2_SENSOR,10,RL0,SmokeCurve);
                                        AirQuality-Multiple_Gas_Sensor1_4.ino:  Ro1 = MQCalibration(MQ6_SENSOR,10,RL1,LPGCurve);
                                        AirQuality-Multiple_Gas_Sensor1_4.ino:  Ro2 = MQCalibration(MQ131_SENSOR,10,RL2,O3Curve);
                                        AirQuality-Multiple_Gas_Sensor1_4.ino:  Ro3 = MQCalibration(TGS2600_SENSOR,10,RL3,C2H5OH_terCurve);
                                        AirQuality-Multiple_Gas_Sensor1_4.ino:  Ro4 = MQCalibration(MQ135_SENSOR,10,RL4,CO_secCurve);
                                        AirQuality-Multiple_Gas_Sensor1_4.ino:  Ro6 = MQCalibration(TGS2602_SENSOR,1,RL6,C7H8Curve);
                                        ....
                                        AirQuality-Multiple_Gas_Sensor1_4.ino:float MQCalibration(int mq_pin, double ppm, double rl_value,float *pcurve )
                                        

                                        Th function MQCalibration should calibrate the sensor in clean air, the calibration function uses the PPM concentration of the gas in a clean air environment.
                                        You already use the appropriate value for i.e. CO2 (around 399 PPM) in the MQ135 sketch - but why are you using those obscure values in the calibration (1, 10) here?

                                        Thanks in advance!

                                        epierreE Offline
                                        epierreE Offline
                                        epierre
                                        Hero Member
                                        wrote on last edited by
                                        #163

                                        @wreiner said:

                                        Th function MQCalibration should calibrate the sensor in clean air, the calibration function uses the PPM concentration of the gas in a clean air environment.
                                        You already use the appropriate value for i.e. CO2 (around 399 PPM) in the MQ135 sketch - but why are you using those obscure values in the calibration (1, 10) here?

                                        Well, I didn't know the concentration in clean air so I had to put in a value even random... I took the hypothesis there are very few in the air so low value.

                                        z-wave - Vera -> Domoticz
                                        rfx - Domoticz <- MyDomoAtHome <- Imperihome
                                        mysensors -> mysensors-gw -> Domoticz

                                        1 Reply Last reply
                                        0
                                        • epierreE epierre

                                          @tantt2810 said:

                                          Hi everyone,
                                          I have an CO2 MG811 sensor. I don't know where tcm pin connect with ?
                                          Please help me. Thank you so much !!!!

                                          this is an analogic sensor, so VCC/Gnd to power it, and readings on analogic Aout

                                          tantt2810T Offline
                                          tantt2810T Offline
                                          tantt2810
                                          wrote on last edited by
                                          #164

                                          @epierre
                                          Thank you. Your mean is Vcc->5V, GND->GND, Dout->Digital pin, Aout->Analog pin. Is it right?
                                          But I don't know the tcm pin connect with ? I have read datasheet but I don't find any info about tcm pin. Please help me. Thank you so much !!!

                                          epierreE 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          14

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular