How to interface MQ-2 Gas Sensor with Arduino Uno (with Code and Library)

Sdílet
Vložit
  • čas přidán 10. 09. 2024
  • #Arduino​ #Smoke​ #Detector​
    What is a Gas Sensor?
    They are electronic devices that detect and identify different types of gasses. They are commonly used to detect toxic or explosive gasses and measure gas concentration.
    In this project, I have interfaced a Gas Sensor with Arduino that displays the contents of various gases in the atmosphere. The MQ-2 Gas Sensor can detect a list of Gases along with Smoke.
    So incase you are looking out for a smoke detector, you can modify the same program for smoke detection.
    Components List:
    Arduino Uno : amzn.to/3eAvyJl
    MQ-2 Gas Sensor : amzn.to/3nbnKl8
    LCD 16x2 with I2C Module : amzn.to/3sByuKE
    Jumper Cables : amzn.to/3v3juGM
    MQ-2 Sensor Code and Libraries :
    github.com/rol...
    Library
    www.electronic...
    Code : www.electronic...
    LCD tutorial : • LCD 16x2 interfaced wi...
    Read the Post at : www.electronicssimplified.in
    Background Music
    - Lichu - Island
    - • Lichu - Island
    Please show some love.
    Like | Share | Subscribe
    #GasSensor​​ #Arduino​#SmokeDetector​#Gases​

Komentáře • 178

  • @shramiksalgaonkar8635
    @shramiksalgaonkar8635 Před 3 lety +13

    One of the most detailed video on youtube. Great work sir...

  • @denzilpillay7986
    @denzilpillay7986 Před 3 lety +3

    I am using this video as part of my project and when you listed all the materials I bought them , you mentioned that we should but Male to Female but went on to use Male to Male.

    • @rolanpereira7643
      @rolanpereira7643 Před 3 lety

      Female to male is preferably. But a jumper cable set is what is mentioned in the video.

    • @ElectronicsSimplified7
      @ElectronicsSimplified7  Před 3 lety

      Jumper cable set is listed in the components.
      Please use the links below.
      If you have existing jumper cables then male to female are preferred as they would replace the use of even a breadboard.

  • @bhaskarg8438
    @bhaskarg8438 Před 2 lety +16

    Better if you also explain the code logic with respective to the components assembled to Arduino, Thank you

  • @AnshumanAtrey
    @AnshumanAtrey Před rokem +2

    will it work directly with a laptop and no battery?
    my LCD only shows blue light
    I am using 400 point breadboard
    The I2C module is already connected to LCD
    please help sir

  • @satishmohitsatish1730
    @satishmohitsatish1730 Před 2 lety +4

    Sir how to connect alarm in this project if lpg or another harmful gas leakage happened

  • @shashanktg08
    @shashanktg08 Před rokem +1

    i did the same way as shown it turned on as it was to be but there is no reading on the lcd what is the problem

  • @sanjaykhatri6093
    @sanjaykhatri6093 Před 3 měsíci

    My code is loaded sucessfully but all the values are showing 0 then what to does we have to wait for 5 minutes for heating and even after bringing the smoke near the mq2 sensor there is no reading on LCD

  • @TheIQ127
    @TheIQ127 Před 11 měsíci +1

    can you please give me the vision of liquidi2c library please

    • @ElectronicsSimplified7
      @ElectronicsSimplified7  Před 11 měsíci

      www.electronicssimplified.in/wp-content/uploads/2023/06/LiquidCrystal_I2C.zip

  • @ayushtiwari46
    @ayushtiwari46 Před 2 lety +3

    Bro I want to add gsm module in it also how may I do that
    ????????........plz reply

  • @trinican2
    @trinican2 Před 3 lety +5

    I enjoyed your tutorial but I have two questions. 1. Does the MQ2 library automatically includes the calibration in gas type and ppm ? 2. I would like to do the same with an MQ9 to measure natural gas in ppm. Is there an equivalent MQ9 library and would the command syntax be the same ? Thanks very much.

    • @ElectronicsSimplified7
      @ElectronicsSimplified7  Před 3 lety

      1.The library of MQ2 includes the calibration for all the gases MQ2 sensor can detect.
      2. github.com/mdsiraj1992/Gassensors visit this link and access all the libraries for MQ gas sensors.
      Thank you!

  • @azuraaishah61
    @azuraaishah61 Před 3 měsíci

    lcd.print((smoke*100)/1000000);
    what is the purpose of this formula?

  • @kushals2538
    @kushals2538 Před 7 měsíci

    i have given the correct commands and connections but the lcd is not powering up

  • @johnpatrickabsalon2221
    @johnpatrickabsalon2221 Před rokem +1

    what type of Arduino is this? can i use arduino uno r3 DIP?

  • @prashadnaik1208
    @prashadnaik1208 Před 3 lety +4

    Well explained Sir

  • @rampagegaming5645
    @rampagegaming5645 Před rokem +2

    Is this working by using MQ135 sensor?

  • @sriyakanuri4453
    @sriyakanuri4453 Před 8 měsíci +1

    Hi, i've the lcd but do not have the i2c coverter, so how do i interface it?

  • @manojmodapalli1635
    @manojmodapalli1635 Před rokem +1

    sir i did the same connection shown in the viedo , lcd display was working but it didnt show the detection percentage as shown in the viedo how can i fix this problem , thank you

  • @Crazy_22119
    @Crazy_22119 Před rokem

    lcd.begin();//Defining 16 columns and 2 rows of lcd display . Bro in this line i am getting error. Pls help me .its an emergency pls . I have school project

  • @razzheenshyrickadelacruz5233

    I tried doing this project. However, the smoke cannot be detected. The value displayed for smoke is at 0% only. Only the values of LPG and CO are read. How can I fix this?

    • @thatwasparticia6671
      @thatwasparticia6671 Před rokem

      Help, what did you do

    • @ElectronicsSimplified7
      @ElectronicsSimplified7  Před rokem +1

      You probably have changed the code and failed to display it.

    • @bryanlanchimba4740
      @bryanlanchimba4740 Před 9 měsíci

      ​@@thatwasparticia6671 I think it is because we transformed the smoke reading into a percentage. The value is very small and could not be read. I removed this 100/1000000 part and started reading the smoke.

  • @deadlyvenom5804
    @deadlyvenom5804 Před 10 měsíci +1

    Dude smoke ppml is not calculating any solution??

    • @dilj1439
      @dilj1439 Před 9 měsíci

      Where is the code .?.???

  • @muhammadnawzad1680
    @muhammadnawzad1680 Před 7 měsíci

    Hi i have some question
    1- for the measurement how to calibrate it ?
    2- what is the range that read for LPG in PPM ? Maximum & Minimum?

  • @akshaypatil8467
    @akshaypatil8467 Před rokem +2

    Can we used multiple gas detector sensor

  • @MuhammadSyamil-me8vw
    @MuhammadSyamil-me8vw Před 6 měsíci

    bro in the library there is only lpg,co,and smoke, how do i detect the ch4 then?

  • @khessclarksereno6327
    @khessclarksereno6327 Před 9 měsíci

    Is it possible to measure the level of methane gas only in the mq2 library?

  • @user-rv8vg1dq7k
    @user-rv8vg1dq7k Před rokem +1

    Why it is taking too long to upload the program into Arduino Uno?

  • @ujjwalsinha7385
    @ujjwalsinha7385 Před rokem

    the output is not displayed on the LCD
    what to do?

  • @nsagrawal5444
    @nsagrawal5444 Před rokem +1

    Can you siplyfy the wire connection

  • @Cdswjp
    @Cdswjp Před rokem +1

    Great work bro

  • @erasaniswaroopkumar9124
    @erasaniswaroopkumar9124 Před 10 měsíci

    can u explain the mq7,and mq8 gas sensors interface with arduino uno output data displays in 20*4 display with code

  • @kagisopilane1000
    @kagisopilane1000 Před rokem

    Hi, this is great. My LCd displays lpg: 0 CO:0 Smoke: 0%. Is the problem with the calibration maybe

  • @2JSinc
    @2JSinc Před rokem +2

    Thanks for this, would it be possible for you to add a LPG tank weight monitoring with low level alert, thanks

  • @NotGreig
    @NotGreig Před 9 měsíci

    hello sir, i am receiving a compiling error with my lcd screen. It say's no matching function

  • @Drxxx
    @Drxxx Před 3 lety +2

    Great channel!!

  • @boraicho6276
    @boraicho6276 Před rokem

    Does this sensor (MQ-2) detect Carbon Dioxide concentration ? I only see Carbon Monoxide reading in the video.

  • @ShiwonPrecious
    @ShiwonPrecious Před 5 měsíci

    Is it possible to detect the gas and actually direct it in a particular place

  • @mariyamansari5526
    @mariyamansari5526 Před rokem +1

    Sir i am getting the output on serial monitor but not on LCD

  • @Arman-v9f4i
    @Arman-v9f4i Před 3 lety +2

    Broh! At 3:25 uh said to connect A0 to Analog Pin 0 on Arduino, but uh connected GND to A0 .Can uh plzz tell me which is correct??

    • @rolanpereira7643
      @rolanpereira7643 Před 3 lety +1

      Connect A0 to Analog Pin 0 on Arduino, that's correct.

    • @rolanpereira7643
      @rolanpereira7643 Před 3 lety +1

      Don't go by the wire colors. They are a little similar. And i see why you are confused.

    • @ElectronicsSimplified7
      @ElectronicsSimplified7  Před 3 lety +2

      Please see that A0 on the MQ will be connected to A0 pin on the Arduino. Don't refer the wire colors. See the circuit diagrams. Bingo.

    • @Arman-v9f4i
      @Arman-v9f4i Před 3 lety +1

      @@ElectronicsSimplified7 Ok broh.. Thanks for helping. Im confused by colours.

    • @Arman-v9f4i
      @Arman-v9f4i Před 3 lety +1

      @@rolanpereira7643 Thanks broh!

  • @dr.mithilfaldesai3561
    @dr.mithilfaldesai3561 Před 2 lety +2

    What is the output unit from A0? resistance in milliohms? current in mA?

    • @ElectronicsSimplified7
      @ElectronicsSimplified7  Před 2 lety +1

      It's neither. It will always be voltage levels. That would be ranging from 0V to Vcc (in this case its 0V to 5V)

  • @RitheshMoolya
    @RitheshMoolya Před 2 lety +1

    I need ammonia sensor with display...

  • @NBAK-jx5ud
    @NBAK-jx5ud Před 3 lety +1

    where's the link for the LCD not display.

    • @ElectronicsSimplified7
      @ElectronicsSimplified7  Před 3 lety

      czcams.com/video/UezoCbBSavQ/video.html

    • @NBAK-jx5ud
      @NBAK-jx5ud Před 3 lety +1

      oh wow! very responsive thank you!. hoping you gain million of subscribers! ❤️

  • @kaushikmistry3438
    @kaushikmistry3438 Před rokem +1

    Bro mq2 library is not installing

  • @gourabhaldar6627
    @gourabhaldar6627 Před rokem +1

    If I use MQ135 instead of MQ2 will the code change?

    • @ElectronicsSimplified7
      @ElectronicsSimplified7  Před rokem

      Yes it will change

    • @gourabhaldar6627
      @gourabhaldar6627 Před rokem

      @@ElectronicsSimplified7 ok sir, thanks for the reply. Actually I'm doing this with MQ135 sensor. So can you please tell what changes I need to do in order to run this successfully.
      Thanks in advance.

  • @user-ot3er7ph7q
    @user-ot3er7ph7q Před rokem

    Sir i am getting the output displayed on serial monitor but not on lcd .There are no errors and connections are also proper

    • @ElectronicsSimplified7
      @ElectronicsSimplified7  Před rokem

      Why is the LCD working with other programs? Just check if the LCD can receive data and display some data on it. You might have to adjust your potentiometer at the back of your I2C module.

  • @ShiwonPrecious
    @ShiwonPrecious Před 5 měsíci

    Sir please which code did you use for the gas detector

  • @user-tc9dv7hi2y
    @user-tc9dv7hi2y Před 6 měsíci

    bro can we use c2h4 gas sensor fof same steps behalf of using gas sensor

  • @AmanKumar-es4wp
    @AmanKumar-es4wp Před 2 lety +1

    If any one u have and you know how to program them plzz help

  • @DavidDavis-se8ns
    @DavidDavis-se8ns Před rokem +2

    His "MQ-2" sensor looks like an MQ-135. I know because I bought the same. Only in the Fritzing schematic, an MQ-2 is depicted. MQ-2 is not even suited for carbon dioxide but MQ-135, which he handles at the beginning (I quit watching) does.

    • @ElectronicsSimplified7
      @ElectronicsSimplified7  Před rokem +2

      As an example, a methane (molecular) concentration of 2% means that 2 out of every 100 air molecules is methane. Similarly, a methane concentration of 2 ppm means that 2 out of every 1 million air molecules is methane. Can MQ-2 detect CO2? A short and simple answer to this question is yes, it can detect CO2.
      You can refer to how smoke is mostly a combination of carbon monoxide and carbon dioxide. Mq-2 sensor has the ability to detect. But the measurements are derived from other gas concentration values.

    • @DavidDavis-se8ns
      @DavidDavis-se8ns Před rokem

      @@ElectronicsSimplified7 You are quite right that there is a mathematical correlation between the two. It's just that we do not exhale methane. I believe cows do produce a lot of methane. So there could be one useful application for it 🙂. If you don't want to spend some 30 bucks on a real CO2 sensor you could get the SGP30 from Ali.... for a few dollars. It does a pretty good job in indirectly calculating the CO2 value in the air. Some smart folks on CZcams already found out. I probably will get one too, later on. ...

  • @nirajkalamkar3107
    @nirajkalamkar3107 Před 5 měsíci

    I did the same process which you did but it didn't work the code failed in uploading i didn't changed the code even but still it failed i asked my uncle who is engineer he said this cannot be worked i tried for 4-5 times but it failed

  • @joycechong8907
    @joycechong8907 Před 2 lety +1

    Well explanation!! Nice!
    I have a little question. Since most of the tutorials are used to test for smoke and gas, is that possible to test the human breathing? Thanks!

  • @AmanKumar-es4wp
    @AmanKumar-es4wp Před 2 lety +1

    Sir I have urgent need of this program

  • @carson5702
    @carson5702 Před 2 lety +1

    loved the vid but where can you find the MQ2 sensor library normally because I can't find it.

    • @ElectronicsSimplified7
      @ElectronicsSimplified7  Před 2 lety

      www.amazon.com/Butane-Hydrogen-Sensor-Detector-Module/dp/B0786DH3BW/ref=mp_s_a_1_2?keywords=mq2%2Bsensor&qid=1638064300&sr=8-2&th=1&psc=1

    • @ElectronicsSimplified7
      @ElectronicsSimplified7  Před 2 lety

      github.com/rolan37/MQ-2-Sensor-Interfaced-with-Arduino

  • @157vaibhavibhalerao5
    @157vaibhavibhalerao5 Před rokem +1

    overall price ?

  • @sakshisuvarna3902
    @sakshisuvarna3902 Před rokem

    hello, is it okay to add MQ9 sensor instead of MQ2 and how about library ?
    thanks in advance

    • @ElectronicsSimplified7
      @ElectronicsSimplified7  Před rokem

      No it's not okay ...
      They are two different sensors. They do almost the same job but have been built different over the years.

    • @ElectronicsSimplified7
      @ElectronicsSimplified7  Před rokem +1

      You could download the MQ9 Sensor library from the internet

  • @the_hyper_here3236
    @the_hyper_here3236 Před rokem +1

    sir can you send me working of block diagram

  • @manmangy
    @manmangy Před rokem

    Can we use this to test Chlorine

  • @flemyjose4036
    @flemyjose4036 Před 2 lety

    why the analog output of sensor is being used instead of digital output

    • @ElectronicsSimplified7
      @ElectronicsSimplified7  Před 2 lety

      Digital will just tell us if any particle is sensed or not sensed (0 and 1 - digital).

    • @ElectronicsSimplified7
      @ElectronicsSimplified7  Před 2 lety

      We need to figure out what particle is sensed so we take the analog reading to decided what type of particle is being sensed.

    • @ElectronicsSimplified7
      @ElectronicsSimplified7  Před 2 lety

      Particle ----> Gas (Thats the simplification).
      Thank you for your question!

  • @user-ku3rs5yx5i
    @user-ku3rs5yx5i Před rokem

    How i code into the laptop

  • @edscelavancena2133
    @edscelavancena2133 Před rokem

    how to connect alarm in this project if lpg or another harmful gas leakage happened

  • @diabolsensei
    @diabolsensei Před 2 lety +1

    hi can i get ckt diagram for this project.

  • @wanfiq3191
    @wanfiq3191 Před rokem +1

    can i get example the coding?

  • @imransaeed5536
    @imransaeed5536 Před 2 lety +1

    I am looking to someone to make me whole unit with my logo on it, with packing and detail instructions, how to install it . I need big production of it. Thanks

  • @fakegamer8336
    @fakegamer8336 Před rokem +1

    does mq-2 measure co2 or co?

  • @karthik3889
    @karthik3889 Před rokem +1

    Please give mq 4 library

  • @lydianandaputri1582
    @lydianandaputri1582 Před rokem +1

    mq-6??

  • @loveislikedream
    @loveislikedream Před 2 lety +1

    bro i we do this project without 12 c module

  • @Amazon_offers2
    @Amazon_offers2 Před rokem

    bro can you make this without i2c

  • @AmanKumar-es4wp
    @AmanKumar-es4wp Před 2 lety +1

    Sir I am new student I don't know how to program so plzzz help

  • @advance-maths
    @advance-maths Před rokem +2

    Yesir

  • @awiawi117
    @awiawi117 Před rokem

    i didn t understand the last step in in 9:18 how do it?

    • @ElectronicsSimplified7
      @ElectronicsSimplified7  Před rokem

      You can just upload the code. By selecting your board.

    • @awiawi117
      @awiawi117 Před rokem

      @@ElectronicsSimplified7 what board sorry i am a beginner can you explain a bit more i did everything like the vid i am just stuck at the last part and i need it for tomrow

    • @ElectronicsSimplified7
      @ElectronicsSimplified7  Před rokem

      You can check some basic videos on how to upload code to Arduino Uno.

  • @rsiinvestor450
    @rsiinvestor450 Před 3 lety +2

    *Recomemd by Emanul Perreira*

  • @novestkuvimba1469
    @novestkuvimba1469 Před 2 lety +1

    Hie sir, can you sent us the code for the Arduino.

  • @nandagustiawan6237
    @nandagustiawan6237 Před 2 lety +1

    please library MQ4

  • @venkateshakula7373
    @venkateshakula7373 Před 2 lety +1

    Bro can I have algorithm of this project tonight same project I have doing in my clg.if u interest to help comment your any social media accounts

  • @nagakowshik578
    @nagakowshik578 Před 2 lety

    sir can u plz help me connection of mu project sir
    my project is fire and gas detection system with IOT sir

  • @Arman-v9f4i
    @Arman-v9f4i Před 3 lety +1

    Broh! Can uh plzz give MQ5 library

  • @karthik-gz3oz
    @karthik-gz3oz Před 9 měsíci +1

    bro i want zip files

  • @dextrond.5557
    @dextrond.5557 Před 4 měsíci

    Mq2 sensor can’t differentiate gasses,

    • @ElectronicsSimplified7
      @ElectronicsSimplified7  Před 4 měsíci

      It can detect all those gases. But it can't find out which gas was detected particularly. But by concentration. It can be predicted.
      So in a LPG prone leakage zone. You can set the value. That's the whole purpose.

  • @shamilsalman9175
    @shamilsalman9175 Před 2 lety +1

    add buzzer and gsm module to it

  • @patiencemtonhodza2477
    @patiencemtonhodza2477 Před 2 lety +1

    can l get the code for this project bro

  • @vidhyakoranga9067
    @vidhyakoranga9067 Před 4 měsíci

    Sir please provide the ges sensor code.

  • @AhsanAli-z6i
    @AhsanAli-z6i Před 4 měsíci

    Sir kindly code and library send kr dy

  • @Crazy_22119
    @Crazy_22119 Před rokem +1

    Not working bro 😭

    • @ElectronicsSimplified7
      @ElectronicsSimplified7  Před rokem

      Please explain what is not working in detail. Happy New Year!

    • @Crazy_22119
      @Crazy_22119 Před rokem

      @@ElectronicsSimplified7 i have given all connections everything as per u said when uploading code i uploaded library and i have upload that time problem occurs "16 columns and 2 rows of lcd display" this code is wrong showing i removed that code and uploaded lcd display not show reading

    • @Crazy_22119
      @Crazy_22119 Před rokem

      Pls tell bro very urgent project bro pls 🙏🙏🙏

  • @venkateshakula7373
    @venkateshakula7373 Před 3 lety

    Vision of arduino pls bro it's an urgent

  • @satishmohitsatish1730
    @satishmohitsatish1730 Před 2 lety

    Led have no lights

  • @gregbennett2437
    @gregbennett2437 Před rokem

    DID NOT WORK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • @hemanthjami1287
    @hemanthjami1287 Před 2 lety

    bro code

    • @ElectronicsSimplified7
      @ElectronicsSimplified7  Před 2 lety

      Codes are usually in the description and always on github and my website : www.electronissimplified.in

  • @rafaelbendigo6270
    @rafaelbendigo6270 Před 2 lety +1

    is it necessary to solder his 16pins to work?

    • @ElectronicsSimplified7
      @ElectronicsSimplified7  Před 2 lety +1

      Necessary... If you do not want to solder... Then use a breadboard

    • @rafaelbendigo6270
      @rafaelbendigo6270 Před 2 lety +1

      @@ElectronicsSimplified7 can i pm you ? my lcd doesn't work like yours. the wires are the same how it is in the video.

    • @rafaelbendigo6270
      @rafaelbendigo6270 Před 2 lety +1

      @@ElectronicsSimplified7 i like your video and explanation but the only is not working is my LCD
      pls help .

    • @ElectronicsSimplified7
      @ElectronicsSimplified7  Před 2 lety

      Visit electronicssimplified.in and contact me