How to calibrate an MQ-2 gas sensor || Arduino tutorial

Поділитися
Вставка
  • Опубліковано 8 лют 2025
  • In this short tutorial I'm demonstrating how to calibrate an MQ-2 gas sensor and get your readings in ppm units. I'm assuming you don't want to spend hundreds of dollars for a calibration kit. The method shown in this video is based on a piece of Arduino code created and shared for free by a company called Sandbox Electronics.
    See the original video - How to use gas sensors with Arduino:
    • How to use gas sensors...
    Subscribe to get notified about my new videos:
    / subscription_c. .
    ----------------------------------------------------------------------------------------------
    UA-cam channel: / electron. .
    Google+: plus.google.co...
    Facebook: / electronfunpage
    Twitter: / electronfun
    Website: ElectronFun.com
    ----------------------------------------------------------------------------------------------
    Video, edit, voice by Chris Lorkowski
    Music by RataxesUK - Everything [No Samples Edit]
    / rataxes-everything-no-...

КОМЕНТАРІ • 144

  • @ShiroiAkumaSama
    @ShiroiAkumaSama 7 місяців тому +6

    Finally someone mentioning that heating is a one time process. I was looking for this answer for a while now.

  • @adailyllama4786
    @adailyllama4786 4 роки тому +1

    Many Thanks! Exactly what I needed for my air monitoring project.

  • @rahatkataria1755
    @rahatkataria1755 5 років тому +1

    Dude, That was superb. Thanks for sharing it!

  • @refrion_robotica_automacao
    @refrion_robotica_automacao 5 років тому

    CONGRATULATIONS. YOUR VIDEO WAS VERY USEFULL AND THANK YOU VERY MUCH FOR SHARING THIS INFORMATION. I WAS FACING SOME PROBLEMS WITH FALSE ALARMS , NOW WITH THIS CALIBRATION IT IS WORKING PERFECTELLY.

  • @TobiasDettinger
    @TobiasDettinger 4 роки тому +2

    I have the arduino ads1015, how to write the code for my board properly?

  • @rmus6085
    @rmus6085 4 роки тому +3

    hi thanks for the video its really helps me a lot. But i have one question. For mq-6 how do i set the RL value since mq-6 using the potentiometer?

  • @electronic7979
    @electronic7979 6 років тому

    Excellent

  • @simplesecomumcidadao7592
    @simplesecomumcidadao7592 Рік тому

    Thank you friend, I asked including chatGPT, it just says calibrate, thank you for your simple and understandable explanation. Can I do the same operations on MQ-135?

    • @prestyboy678
      @prestyboy678 Рік тому

      Did it work? I’m trying to do the same with the MQ-135 just measuring carbon dioxide instead.

    • @amnieyzulfikri1789
      @amnieyzulfikri1789 Рік тому

      have you tried on MQ-135? i urgently need it for my project for CO2 detection :(@@prestyboy678

  • @KifPH
    @KifPH 3 місяці тому

    Is the preheating continuous or can i do it in interval? Like 12 hours then later next day another 12 hours

  • @anitakenchannavar6493
    @anitakenchannavar6493 5 років тому +2

    how to detect only the oxygen levels in the air, which sensor i shld use

  • @narima4022
    @narima4022 4 місяці тому

    I bought the one with the board (which have potentiometer, led light, etc.) so, what is the RL value for that? In the sandbox website it was 20kohm, but then it won't read any gas, I even emptied my lighter.

  • @peacecheap
    @peacecheap 8 років тому +2

    In datasheet, mq-2 only can detect LPG in 200-5000 ppm, but in demo it can detect lower than 200 ppm.
    Is it really accurate for measurement of LPG concentration?

    • @ElectronFunCom
      @ElectronFunCom  8 років тому +1

      +Agsen Setyo You are an attentive observer and you are right - the datasheet says 200-5000ppm for LPG. The Sandbox Electronics guys didn't take this into account. This method of calibration will never be as accurate as the "proper" way, but it's free.

  • @rolandberendonck3900
    @rolandberendonck3900 3 роки тому +1

    Do you or anybody know what is a sensative sensor for detecting secondhand smoke (cigarette smoke). I still cannot find such a sensor and a dust laser sensor does not fit because it doesn't distingquish cigarette smoke from any other smoke. Please help.

  • @____________________________.x
    @____________________________.x 8 років тому

    This was useful, thanks

  • @najeebkhan7336
    @najeebkhan7336 8 років тому +1

    Hello Sir. I am Using this calibration code for MQ-7 CO sensor, its work good. But Why sensor does not give any value with out giving smoke?? Please Suggest any Help

  • @konstantinost3185
    @konstantinost3185 8 років тому +1

    This is free air calibration, after calibration when the code is running, the CO ppm result the serial shows is 0, shouldn't it be 20000 (2%) which is the known atmospheric CO% concentrate?

    • @ElectronFunCom
      @ElectronFunCom  8 років тому +1

      As far as I know the sensor omits the atmospheric CO concentration and measures everything above that value. It treats clean air as point 0, but don't cite me on this.

  • @vibhor6685
    @vibhor6685 4 роки тому

    Thanks for sharing dude. Can you please guide how can i get same results with MQ2 sensor with I2C module.

  • @azliluissembanawan4659
    @azliluissembanawan4659 Рік тому

    I need the mq 131 and the mq135 for our research

  • @ghulammehdibhutto1548
    @ghulammehdibhutto1548 8 років тому

    It is helpful video dear but sorry to say this not what we call calibration.. we are still unaware that whether these concentrations of gases are correct or not.. to confirm this we must need a expensive device as u shown in your video.. so problem is still there.. Keep this thing aside i want to know that how to adjust its sensitivity using potentiometer on the circuit board.. when i was testing it i just place it over stove then it was showing readings otherwise not LOL even not by burning a paper.. Do you have any solution..??

    • @ElectronFunCom
      @ElectronFunCom  8 років тому

      It's true, the software calibration is only a cheap substitute of the proper calibration.
      To adjust sensitivity just replace the resistor with a potentiometer.

  • @2012isRonPaul
    @2012isRonPaul 7 років тому +2

    why do i get a reading with 10-digit number (2643534534ppm etc) and the resistance varies after every reboot of the board? (from 3.26 to 15.7kOhms etc) ....

    • @ElectronFunCom
      @ElectronFunCom  7 років тому

      To tell you the truth, I have no idea. Which code have you been using? Have you tried pre-heating your sensor?

  • @idhamidris3481
    @idhamidris3481 7 років тому +1

    Hi ElectronFun,
    I'm currently working on an MQ-3B sensor to detect ethanol. I'm wondering if that sandbox electronics would work for MQ-3 too. If not, have you seen other sites that provide arduino code for that?
    Love your videos. Keep up your good work.

    • @ElectronFunCom
      @ElectronFunCom  7 років тому

      Hi Idham,
      Unfortunately the code was written specifically for the MQ-2 and I'm not aware of any equivalent for the MQ-3.
      Thank you so much for your kind words :)

  • @amvip5929
    @amvip5929 8 років тому +2

    Hi There, Thanks for the code, I tried the code with my MQ sensor and edison board, it gives me values as 0 only. How do I get it to read different values?

  • @syamilfuad5098
    @syamilfuad5098 6 років тому +1

    may i know how do u get LPG, carbon monoxide and smoke tested at the same time??

    • @calirific3503
      @calirific3503 3 роки тому

      you can't, they're combined. So it is all approximates

  • @clip8327
    @clip8327 8 років тому +1

    When hook up MQ-2 with 5V onboard pin, the voltage drop to 4.86V
    Is it better to use the external very smooth 5V regulator ?

    • @ElectronFunCom
      @ElectronFunCom  8 років тому +1

      It's better to use an external power supply, because the MQ-2 consumes up to 160mA, while Arduino Uno can deliver 200mA maximum. If you connect something more than just the sensor, you can burn out your Arduino.

  • @madanmohanraok3649
    @madanmohanraok3649 6 років тому +1

    Hi,
    Great video,
    We are looking for calibration of PMS-5003 Particulate matter sensor.
    Any suggestions?

  • @primevigilante7259
    @primevigilante7259 3 роки тому

    does it work with MQ 6 sensor too?

  • @jumbo999614
    @jumbo999614 2 роки тому

    What is difference between sensor ( 6 pin ) and sensor module (4 pin)?
    Do you have diagram for wiring 6 pin?

  • @turgayolgay3381
    @turgayolgay3381 8 років тому +2

    can you make this software for CH4, H2S, CO2, H2, O2, and CO ?
    Thank you

    • @ElectronFunCom
      @ElectronFunCom  8 років тому

      Unfortunately it's not as easy. The code presented in this video was created by a company called Sandbox Electronics.

    • @syamilfuad5098
      @syamilfuad5098 6 років тому

      have u got the software? if u have may i know where?

  • @rudygabrielsichahuaman321
    @rudygabrielsichahuaman321 4 роки тому

    the 10K resistor is the same for the MQ131 ?

  • @alexpiaro9449
    @alexpiaro9449 7 років тому +1

    Hey thanks for the video , can you help with circuit diagram for MQ7 co detector and its block diagram thanks

  • @MrLiohemanth
    @MrLiohemanth 5 років тому

    Hi there nice video btw can we use same code for mq4 sensor

  • @shaikhahmed7929
    @shaikhahmed7929 7 років тому +1

    I am confused how to translate the different levels of different gases from one ADC level as they all are in an air mixture. Any ideas on that? I mean how one ADC level translates into different ppms for different gases?

    • @ElectronFunCom
      @ElectronFunCom  7 років тому +2

      It is confusing, I agree. The sensor can detect a range of gasses, but it is not able to differentiate which gas it is exposed to. The MQ gas sensors are good to experiment with, for DIY projects, but I wouldn't trust these if you're working on a professional project.

    • @syamilfuad5098
      @syamilfuad5098 6 років тому

      so do u have a solution on what sensor specifically detect what gas??

  • @onjianye9491
    @onjianye9491 6 років тому

    Hi may i know does this example included the adjustment of temperature and humidity around the environment?

  • @matcha5831
    @matcha5831 6 років тому

    Hi i wonder know how to you get this value LPGCurve[3] = {2.3,0.21,-0.47}; and i confused how u can get point2: (lg10000, -0.59) --0.59 from the datasheet given?

  • @mouaddibi4491
    @mouaddibi4491 6 років тому

    HI! thank you for the big job , can you help me for why separated the smoke and an other gaz and thanks .

  • @fannym.ninalaura4160
    @fannym.ninalaura4160 7 років тому +1

    a query how can I calibrate the MQ-8 sensor, I can use the same code that you used to calibrate MQ-2

    • @ElectronFunCom
      @ElectronFunCom  7 років тому

      Unfortunately you can't use the same code, it is sensor specific. I haven't found an equivalent for the MQ-8.

  • @gopikabg5403
    @gopikabg5403 7 років тому +2

    Any caliberation tips for TGS822(acetone sensor)

    • @ElectronFunCom
      @ElectronFunCom  7 років тому

      I haven't tested anything similar, sorry.

  • @edsonpachecojunior6797
    @edsonpachecojunior6797 8 років тому

    This calibration is applicapable for all sensors or only for MQ-2? I aks this because I want to calibrate my ozone gas sensor (MQ-131).

    • @ElectronFunCom
      @ElectronFunCom  8 років тому

      This is only for the MQ-2.

    • @behnamghassaban1718
      @behnamghassaban1718 4 роки тому

      I want to calibrate my ozone gas sensor (MQ131) please help me if you find anything.

  • @myprojects1991
    @myprojects1991 8 років тому

    thanks

  • @muhammedakbas9004
    @muhammedakbas9004 7 років тому +1

    thx for help :)

  • @DhirubhaisNayak
    @DhirubhaisNayak 7 років тому

    How did u connect those 6 wires to mq2 sensor

  • @charanr3387
    @charanr3387 6 років тому

    bro In case we are having different ranges of Air flow sensor(i mean 100 sensors) in a textile industry in which I want to get the exact value by calibrating in it????????????

  • @jilljill3712
    @jilljill3712 7 років тому +1

    hi thanks for the video,can you help me ,How do I can make it alert through speakers?

    • @ElectronFunCom
      @ElectronFunCom  7 років тому

      Thanks for your comment :)
      You could use the tone function, see here: www.arduino.cc/en/Reference/Tone.

    • @jilljill3712
      @jilljill3712 7 років тому +1

      thank you :)

    • @ElectronFunCom
      @ElectronFunCom  7 років тому

      No problem :)

  • @junerilllayna252
    @junerilllayna252 7 років тому

    Aside from MQ 2, do you have codes for MQ 136 and MQ 131? waiting for your response.

    • @ElectronFunCom
      @ElectronFunCom  7 років тому

      No, I don't have any other codes, sorry.

  • @labspedia1480
    @labspedia1480 8 років тому

    Good video! I need a code that allow me calibrate my sensor of alcohol (MQ-3)

    • @ElectronFunCom
      @ElectronFunCom  8 років тому

      Thanks! I'm afraid there is no such code for an MQ-3.

  • @robotic1413
    @robotic1413 7 років тому +1

    How do i select the RL value if the sensor i have is already fixed with a potentiometer?

    • @ElectronFunCom
      @ElectronFunCom  7 років тому

      I guess you don't have to, because the resistor is probably already there :)

  • @hilman9032
    @hilman9032 5 років тому

    can someone tell me please, where did i can get code for mq 135 is?

  • @andreaspapadakis8097
    @andreaspapadakis8097 7 років тому +1

    Hey, I am using an mq4 and mq7 to detect CO and Methane Concetrations. Do u think the sanbox electronics code will work for those mq sensors when I input the Load resistance i have put for them?

    • @ElectronFunCom
      @ElectronFunCom  7 років тому

      The code will not work properly with your configuration. It was created specifically for the MQ-2.

    • @andreaspapadakis8097
      @andreaspapadakis8097 7 років тому

      Thanks for replying so soon, do you have any tips for how to find the correct Load Resistance for the MQ7 which has an adjustable one, and how to calibrate it afterwards?

    • @ElectronFunCom
      @ElectronFunCom  7 років тому

      No problem :)
      I haven't experimented with the MQ7. I'm afraid the only way to have reliable readings could be the proper calibration.

    • @deepaksubhedar5737
      @deepaksubhedar5737 7 років тому

      Do you get any solution of this problem. Plz help me if you get ???

  • @ZechariahPad
    @ZechariahPad 8 років тому

    hello.does this code also same with any sensor such mq4?
    tq

    • @ElectronFunCom
      @ElectronFunCom  8 років тому

      You can use the same code for MQ-4, but it's not for every single sensor.

  • @iamnotyou1886
    @iamnotyou1886 7 років тому +1

    Can u post the schematic for this?

    • @ElectronFunCom
      @ElectronFunCom  7 років тому

      Sure, you can find more details on my website: electronfun.com/project_2.php.

  • @warkopproduction9510
    @warkopproduction9510 5 років тому

    can i use the code with MQ135?

  • @vunnammaniprashanth5604
    @vunnammaniprashanth5604 6 років тому

    there is no link found for coding can you please
    provide that

  • @abdulkreemalsultan134
    @abdulkreemalsultan134 4 роки тому

    Where to find gas mass flow meter? Any one can help me

  • @vanshgupta24
    @vanshgupta24 8 років тому +1

    Sir what can i do for mq2 Sensor with 3 Pins for connection on arduino and breadboard

    • @ElectronFunCom
      @ElectronFunCom  8 років тому +2

      You can simplify your circuit. Just connect 5V and GND to your sensor. Next connect the remaining pin to your Arduino's analog input. You don't have to worry about additional resistors.

  • @ashzz999
    @ashzz999 8 років тому

    any calibration tips for h2 gas?

    • @ElectronFunCom
      @ElectronFunCom  8 років тому

      +ashraf zin Sorry, Sandbox Electronics didn't include H2 in the code, so I guess the only way is to go through the "proper" calibration.

    • @jeromejones8164
      @jeromejones8164 8 років тому +1

      what is the proper method of calibration?

    • @ElectronFunCom
      @ElectronFunCom  8 років тому

      +Jerome Jones There are special kits on the market, thanks to which you are able to get a specific gas concentration in PPM units. You can expose your sensor to the gas and map the value you're getting from your sensor.

    • @ElectronFunCom
      @ElectronFunCom  8 років тому

      You need special equipment for it.

    • @samunibay9014
      @samunibay9014 8 років тому +1

      Hi would it be possible to post a link to the calibration equipment you found for calibrating the sensors?

  • @walkindream3908
    @walkindream3908 7 років тому +1

    hi! i'm using mq-2.
    Why the output value is zero?

    • @ElectronFunCom
      @ElectronFunCom  7 років тому

      Have you connected everything correctly? If you're using a breadboard I would also check your jumper wires - some of them might be faulty.

  • @parthpatel4101
    @parthpatel4101 8 років тому

    How did you determine that Rl=5.1 works for you?

    • @ElectronFunCom
      @ElectronFunCom  8 років тому +1

      +Parth Patel The sensitivity seemed the most reasonable with about 5kohms. However, each individual sensor may react a little bit differently, so there's no specific recipe.

  • @Mohammadsharifoffical.
    @Mohammadsharifoffical. 6 років тому

    How to implement the formula....

  • @revandyrizky4406
    @revandyrizky4406 3 роки тому

    How to calibrate mq7

  • @didikwahyu8339
    @didikwahyu8339 6 років тому

    hi sir how to get LPGCurve[3] = {2.3,0.21,-0.47} ?

    • @ExtantFrodo2
      @ExtantFrodo2 5 років тому

      LPGCurve[3] = {2.3,0.21,-0.47};
      //two points are taken from the curve.
      //with these two points, a line is formed which is "approximately equivalent" to the original curve.
      //data format:{ x, y, slope}; point1: (lg200, 0.21), point2: (lg10000, -0.59)

  • @قناةكراميش-ش2م
    @قناةكراميش-ش2م 7 років тому +1

    can you write the arduino code

    • @ElectronFunCom
      @ElectronFunCom  7 років тому +1

      The code is available here: sandboxelectronics.com/?p=165.

  • @fatihustaoglu1995
    @fatihustaoglu1995 5 років тому

    This URL is for those who cannot find the code;
    sandboxelectronics.com/?p=165

    • @Chupria
      @Chupria 4 роки тому

      Thank you...I thought they removed the code for some reason...but it's up and alive.

  • @trixiemagdua4583
    @trixiemagdua4583 2 роки тому

    Hello sir can i ask how can i improve the range of a sensor?

  • @Alexelectricalengineering
    @Alexelectricalengineering 8 років тому

    Thumbs up :)
    Alex

  • @hadjer7998
    @hadjer7998 4 роки тому

    I nées code of MQ4

  • @imturki6217
    @imturki6217 7 років тому

    programe plesea

    • @ElectronFunCom
      @ElectronFunCom  7 років тому

      You can find the project page and code here: electronfun.com/project_2.php.

  • @mdtowhidurrahmankha4237
    @mdtowhidurrahmankha4237 8 років тому

    bro can i use more then 1 mq 2 in anduino bord???

    • @ElectronFunCom
      @ElectronFunCom  8 років тому

      Sure you can, just use one individual analog pin for every sensor connected to your Arduino.

  • @scorpion7434
    @scorpion7434 7 років тому +1

    I challenge you to give me explanation of the weird use of the natural logarithm in the final step of the code. Even the maths experts couldn't tell me. COPY_PASTE baby!
    Added to that, can you provide a clean air -- a real clean air, for detecting CO2 for example, where can ya find an air that doesn't contain any CO2 to be a reference to your R0?
    Using those sensors are not accurate at all. they're just to detect if gas exists or not. To make them accurate you need a huge knowledge in maths, and that what I'm trying to do in my project (a real work project)!

    • @ElectronFunCom
      @ElectronFunCom  7 років тому

      The piece of code is taken from a company called Sandbox Electronics. You can find this information in the video description.
      These sensors are good for DIY builds, but I wouldn't use them in any commercial project, which I mentioned many times in the comments section.
      Good luck with your project.

    • @scorpion7434
      @scorpion7434 7 років тому

      Thanks for your reply. FINALLY someone of those who publsih videos responded to me (I just used the word "challenge" trying to make you move as I thought you're like some others who just ain't respond). Indeed it should not be used for commercial purpose, but I am in a research unit, so I will not use them until I make sure that I'm getting enough accurate readings, I'm working around this problem. I will use a certified device to compare my result with it for the particular gases. However, thanks for your wishes :)
      P.S and BTW SandBox is not responding to any query. I wonder if they also just copy-paste the code ;-)

    • @ElectronFunCom
      @ElectronFunCom  7 років тому

      My channel is quite small, so at that point I'm able to reply to pretty much every single comment. Sometimes it takes a few days to a week, because I have a 'regular' job and a life outside of UA-cam :) Some UA-cam creators receive hundreds of comments a day and more, so they reply to very few of them.
      I didn't realize research units use UA-cam as a source of knowledge/inspiration.
      You want to compare a commercial sensor with the MQ series - I wonder what results you will get.
      I haven't contacted SandBox Electronics, but I know this project is quite old. I'm not sure if they still support it. However, it would look much more professional if they replied to your query.

    • @scorpion7434
      @scorpion7434 7 років тому

      Ya assumed they have big channel, believe me, most of who I asked have smaller than yours.
      I'm a software developer, and I'm doing my internship in IoT Unit (actually it's a research centre), I've been assigned a whole project in a field that I'm not familiar to. That's why I'm looking at every single source I come across. A lot of explanation needed and are not available from the source (a nice looking video with a title of "How to" but with no deep explanation), I now have a full view of the logic behind all of this, but one more left which is the use of this weird and unexpected natural logarithm (ln(y)) in the final step of the calculation. If ya have any query about the code or the logic please don't hesitate.
      P.S the idea of the project is to DIY from scratch and achieve very impressive and accurate device as a prototype with very low cost.

    • @ElectronFunCom
      @ElectronFunCom  7 років тому

      That's a very ambitious project, as cutting cost usually makes the whole thing less accurate and reliable.
      What kind of software do you develop, if it's not a secret?

  • @pong301275cmu
    @pong301275cmu 8 років тому +1

    this is not a calibration method.

  • @gurpreetkourkamthekar8630
    @gurpreetkourkamthekar8630 7 років тому +1

    Can u tell me how much area this mq2 sensor can cover???

    • @ElectronFunCom
      @ElectronFunCom  7 років тому

      There is no such info in the datasheet as far as I remember, but I can tell you it's not a large area. I'd say a couple of centimeters/inches.