{"product_id":"methane-gas-sensor-mq-4-module","title":"Methane Gas Sensor MQ-4 Module","description":"\u003cp\u003e\u003cspan\u003eDetects the presence of of methane gas in the air as is found in natural gas (CNG).\u003c\/span\u003e\u003c\/p\u003e\n\u003ch2\u003eDescription\u003c\/h2\u003e\n\u003cp\u003eThe Methane Gas Sensor MQ-4 Module detects the presence of of methane gas in the air as is found in natural gas (CNG).\u003c\/p\u003e\n\u003ch2\u003e\u003cstrong\u003ePACKAGE INCLUDES:\u003c\/strong\u003e\u003c\/h2\u003e\n\u003cul\u003e\n\u003cli\u003eMethane Gas Sensor MQ-4 Module\u003c\/li\u003e\n\u003c\/ul\u003e\n\u003ch2\u003e\u003cstrong\u003eKEY FEATURES OF METHANE GAS SENSOR MQ-4 MODULE:\u003c\/strong\u003e\u003c\/h2\u003e\n\u003cul\u003e\n\u003cli\u003eSensor type used to detect natural gas leak in home\u003c\/li\u003e\n\u003cli\u003eAnalog sensor output\u003c\/li\u003e\n\u003cli\u003eDigital sensor output with user adjustable sensitivity and LED indicator\u003c\/li\u003e\n\u003cli\u003e5V operation\u003c\/li\u003e\n\u003c\/ul\u003e\n\u003cp\u003eThe module includes the MQ-4 sensor which provides a direct analog output. In addition, the module has an LM393 comparator IC and adjustment potentiometer to provide a digital output with an adjustable set-point, power LED, digital output active LED and a header for easy hookup.\u003c\/p\u003e\n\u003cp\u003eThese modules can be used to detect the presence and amount of methane \/ natural gas present in the air.  This can be used to create an alarm for monitoring the presence of a gas leak or any other source of methane such as flatulence if you should be so inclined.\u003c\/p\u003e\n\u003ch3\u003eHeating Element\u003c\/h3\u003e\n\u003cp\u003eThe sensor contains a small heater, so the power draw is about 150mA.  The sensor will get warm to the touch after it has been operating for awhile.  The module can be powered off a 5V power pin on the uC, but it draws too much power to try to power it off a digital pin.\u003c\/p\u003e\n\u003cp\u003eFor accurate measurement, the sensor needs to be fully warmed up.  The sample code below has a 1 minute warm-up, but for maximum accuracy the warm-up time before taking a reading can be extended.\u003c\/p\u003e\n\u003ch3\u003eSensing Element\u003c\/h3\u003e\n\u003cp\u003eThe sensor uses SnO2 (tin dioxide) for the sensing element which is heated and changes resistance when exposed to methane vapors in the air.  A voltage divider is used to provide an analog output voltage that correlates to the amount of natural gas in the air.   When the sensor is left in storage, the calibration of the device can drift.  When first being put into use, the mfr recommends operating it for 48 hours before relying upon the accuracy of its readings.  For experimenting, running for an hour seems to settle down the readings enough to start working with the device.\u003c\/p\u003e\n\u003ch3\u003eAdjusting Digital Output Trip-point\u003c\/h3\u003e\n\u003cp\u003eIf using the DO (Digital Output), a potentiometer on the module allows for the sensitivity of the trip-point to be adjusted.  When the level of gas exceeds the trip-point, the DO output will go LOW and the DO-LED will light.\u003c\/p\u003e\n\u003ch3\u003eModule Connections\u003c\/h3\u003e\n\u003cp\u003eThere is a header on the module for making connections\u003c\/p\u003e\n\u003cp\u003e\u003cstrong\u003e1 x 4 Header\u003c\/strong\u003e\u003c\/p\u003e\n\u003cul\u003e\n\u003cli\u003e\n\u003cstrong\u003eVCC\u003c\/strong\u003e\u003cspan\u003e \u003c\/span\u003e= Connect to 5V\u003c\/li\u003e\n\u003cli\u003e\n\u003cstrong\u003eGND\u003c\/strong\u003e\u003cspan\u003e \u003c\/span\u003e= Connect to ground\u003c\/li\u003e\n\u003cli\u003e\n\u003cstrong\u003eD0\u003c\/strong\u003e\u003cspan\u003e \u003c\/span\u003e= Digital output of comparator circuit.  Active LOW when gas is detected\u003c\/li\u003e\n\u003cli\u003e\n\u003cstrong\u003eA0\u003c\/strong\u003e\u003cspan\u003e \u003c\/span\u003e= Analog output of sensor. Voltage increases with the amount of gas detection\u003c\/li\u003e\n\u003c\/ul\u003e\n\u003ch2\u003e\u003cstrong\u003eOUR EVALUATION RESULTS:\u003c\/strong\u003e\u003c\/h2\u003e\n\u003cp\u003eThese devices work very well to detect the presence of natural gas \/ methane gas (CH4) and provide an analog output relative to the amount of gas that is detected as well as a digital output once the gas level exceeds the set-point.\u003c\/p\u003e\n\u003cp\u003eBe aware that temperature and humidity have an effect on the readings.  This can be demonstrated by running the sample program below and blowing on the sensor.  The sensor reading will go up. The sensor has a built-in heater required for correct operation of the sensor, so for best stability it should be given some time to heat up (sensor warm to the touch) which will minimize the effect of temperature.\u003c\/p\u003e\n\u003cp\u003eIn our testing using the code below, the sensor analog reading runs at about 30 after it has had a couple of hours to break-in.  When initially used, it is good to let the module idle while running this program and keeping an eye on the reading.  You will see it drift down for a while and then start to stabilize at which point it is ready to use.\u003c\/p\u003e\n\u003cp\u003eTo test the basic sensor operation, a gas stove burner was turned on without starting a flame and some natural gas collected in a zip-lock bag that was held over the burner for a few moments (be sure to turn the burner off afterwards).  The sensor was then placed in the bag and a reading of 350 was obtained.  Based on the level of rotten egg smell in the bag after conducting the test a couple of times, an initial alert setting of 250 was deduced.  The digital output was also adjusted to trip at about that same point using the same zip-lock bag trick.  Not a very scientific calibration process by any means, but at least it gives a starting point.\u003c\/p\u003e\n\u003cp\u003eThe program below uses pin A0 for the analog input but this can be any analog pin.  The digital output is brought into pin 8 but these can be any digital pin.  The reading is taken every second and reported out to the Serial Monitor window.\u003c\/p\u003e\n\u003ch3\u003eMethane Gas Sensor MQ-4 Module Example Program\u003c\/h3\u003e\n\u003cpre class=\"copy-the-code-target\"\u003e\u003cspan\u003e\/*  MOQ-4 Natural Sensor Module Test\u003c\/span\u003e\n\n\u003cspan\u003e   This type of sensor is commonly used for detecting natural gas \/ methane leaks\u003c\/span\u003e\n\u003cspan\u003e   which might include flatulence.\u003c\/span\u003e\n\u003cspan\u003e   \u003c\/span\u003e\n\u003cspan\u003e   Monitor sensor analog output 'A0' on ADC input A0\u003c\/span\u003e\n\u003cspan\u003e   Monitor sensor digital output 'D0' on digital input pin 8\u003c\/span\u003e\n\u003cspan\u003e*\/\u003c\/span\u003e\n\u003cspan\u003e\/\/ Define pins used below\u003c\/span\u003e\n\u003cspan\u003e#define\u003c\/span\u003e \u003cspan\u003eADC_PIN\u003c\/span\u003e \u003cspan\u003eA0\u003c\/span\u003e      \u003cspan\u003e\/\/ Use any available ADC Pin, connect to A0 sensor pin\u003c\/span\u003e\n\u003cspan\u003e#define\u003c\/span\u003e \u003cspan\u003eDIGITAL_PIN\u003c\/span\u003e \u003cspan\u003e8\u003c\/span\u003e   \u003cspan\u003e\/\/ Use any available digital pin, connect to D0 sensor pin\u003c\/span\u003e\n\u003cspan\u003e#define\u003c\/span\u003e \u003cspan\u003eWARMUP_TIME\u003c\/span\u003e \u003cspan\u003e30\u003c\/span\u003e  \u003cspan\u003e\/\/ Warmup time in Seconds\u003c\/span\u003e\n\u003cspan\u003e#define\u003c\/span\u003e \u003cspan\u003eGAS_ALERT\u003c\/span\u003e \u003cspan\u003e250\u003c\/span\u003e   \u003cspan\u003e\/\/ Level at which to raise alert\u003c\/span\u003e\n\n\u003cspan\u003e\/\/===============================================================================\u003c\/span\u003e\n\u003cspan\u003e\/\/  Initialization\u003c\/span\u003e\n\u003cspan\u003e\/\/===============================================================================\u003c\/span\u003e\n\u003cspan\u003evoid\u003c\/span\u003e \u003cspan\u003esetup\u003c\/span\u003e\u003cspan\u003e(\u003c\/span\u003e\u003cspan\u003e)\u003c\/span\u003e\n\u003cspan\u003e{\u003c\/span\u003e\n  \u003cb\u003e\u003cspan\u003eSerial\u003c\/span\u003e\u003c\/b\u003e\u003cspan\u003e.\u003c\/span\u003e\u003cspan\u003ebegin\u003c\/span\u003e\u003cspan\u003e(\u003c\/span\u003e\u003cspan\u003e9600\u003c\/span\u003e\u003cspan\u003e)\u003c\/span\u003e\u003cspan\u003e;\u003c\/span\u003e          \u003cspan\u003e\/\/ Set Serial Monitor window comm speed\u003c\/span\u003e\n  \u003cb\u003e\u003cspan\u003eSerial\u003c\/span\u003e\u003c\/b\u003e\u003cspan\u003e.\u003c\/span\u003e\u003cspan\u003eprintln\u003c\/span\u003e\u003cspan\u003e(\u003c\/span\u003e\u003cspan\u003e\"Warming up the sensor \"\u003c\/span\u003e\u003cspan\u003e)\u003c\/span\u003e\u003cspan\u003e;\u003c\/span\u003e  \u003cspan\u003e\/\/Wait while we warm up the sensor\u003c\/span\u003e\n  \u003cspan\u003efor\u003c\/span\u003e \u003cspan\u003e(\u003c\/span\u003e\u003cspan\u003eint\u003c\/span\u003e \u003cspan\u003ei\u003c\/span\u003e\u003cspan\u003e=\u003c\/span\u003e\u003cspan\u003e0\u003c\/span\u003e\u003cspan\u003e;\u003c\/span\u003e \u003cspan\u003ei\u003c\/span\u003e\u003cspan\u003e\u0026lt;=\u003c\/span\u003e \u003cspan\u003eWARMUP_TIME\u003c\/span\u003e\u003cspan\u003e;\u003c\/span\u003e \u003cspan\u003ei\u003c\/span\u003e\u003cspan\u003e++\u003c\/span\u003e\u003cspan\u003e)\u003c\/span\u003e \u003cspan\u003e{\u003c\/span\u003e\n    \u003cb\u003e\u003cspan\u003eSerial\u003c\/span\u003e\u003c\/b\u003e\u003cspan\u003e.\u003c\/span\u003e\u003cspan\u003eprint\u003c\/span\u003e\u003cspan\u003e(\u003c\/span\u003e\u003cspan\u003e\". \"\u003c\/span\u003e\u003cspan\u003e)\u003c\/span\u003e\u003cspan\u003e;\u003c\/span\u003e\n    \u003cspan\u003edelay\u003c\/span\u003e\u003cspan\u003e(\u003c\/span\u003e\u003cspan\u003e1000\u003c\/span\u003e\u003cspan\u003e)\u003c\/span\u003e\u003cspan\u003e;\u003c\/span\u003e\n  \u003cspan\u003e}\u003c\/span\u003e\n  \u003cb\u003e\u003cspan\u003eSerial\u003c\/span\u003e\u003c\/b\u003e\u003cspan\u003e.\u003c\/span\u003e\u003cspan\u003eprintln\u003c\/span\u003e\u003cspan\u003e(\u003c\/span\u003e\u003cspan\u003e\" Warmup Complete\"\u003c\/span\u003e\u003cspan\u003e)\u003c\/span\u003e\u003cspan\u003e;\u003c\/span\u003e\n\u003cspan\u003e}\u003c\/span\u003e\n\u003cspan\u003e\/\/===============================================================================\u003c\/span\u003e\n\u003cspan\u003e\/\/  Main\u003c\/span\u003e\n\u003cspan\u003e\/\/===============================================================================\u003c\/span\u003e\n\u003cspan\u003evoid\u003c\/span\u003e \u003cspan\u003eloop\u003c\/span\u003e\u003cspan\u003e(\u003c\/span\u003e\u003cspan\u003e)\u003c\/span\u003e\n\u003cspan\u003e{\u003c\/span\u003e\n  \u003cspan\u003eint\u003c\/span\u003e \u003cspan\u003eval_ADC\u003c\/span\u003e \u003cspan\u003e=\u003c\/span\u003e \u003cspan\u003eanalogRead\u003c\/span\u003e\u003cspan\u003e(\u003c\/span\u003e\u003cspan\u003eADC_PIN\u003c\/span\u003e\u003cspan\u003e)\u003c\/span\u003e\u003cspan\u003e;\u003c\/span\u003e          \u003cspan\u003e\/\/ Read analog value from sensor\u003c\/span\u003e\n  \u003cspan\u003eint\u003c\/span\u003e \u003cspan\u003eval_Digital\u003c\/span\u003e \u003cspan\u003e=\u003c\/span\u003e \u003cspan\u003edigitalRead\u003c\/span\u003e\u003cspan\u003e(\u003c\/span\u003e\u003cspan\u003eDIGITAL_PIN\u003c\/span\u003e\u003cspan\u003e)\u003c\/span\u003e\u003cspan\u003e;\u003c\/span\u003e \u003cspan\u003e\/\/ Read  digital value from sensor\u003c\/span\u003e\n  \u003cb\u003e\u003cspan\u003eSerial\u003c\/span\u003e\u003c\/b\u003e\u003cspan\u003e.\u003c\/span\u003e\u003cspan\u003eprint\u003c\/span\u003e\u003cspan\u003e(\u003c\/span\u003e\u003cspan\u003e\"Natural Gas Analog Data = \"\u003c\/span\u003e\u003cspan\u003e)\u003c\/span\u003e\u003cspan\u003e;\u003c\/span\u003e \u003cspan\u003e\/\/ Printout the raw data\u003c\/span\u003e\n  \u003cb\u003e\u003cspan\u003eSerial\u003c\/span\u003e\u003c\/b\u003e\u003cspan\u003e.\u003c\/span\u003e\u003cspan\u003eprint\u003c\/span\u003e\u003cspan\u003e(\u003c\/span\u003e\u003cspan\u003eval_ADC\u003c\/span\u003e\u003cspan\u003e)\u003c\/span\u003e\u003cspan\u003e;\u003c\/span\u003e\n\n  \u003cb\u003e\u003cspan\u003eSerial\u003c\/span\u003e\u003c\/b\u003e\u003cspan\u003e.\u003c\/span\u003e\u003cspan\u003eprint\u003c\/span\u003e\u003cspan\u003e(\u003c\/span\u003e\u003cspan\u003e\"tDigital Output = \"\u003c\/span\u003e\u003cspan\u003e)\u003c\/span\u003e\u003cspan\u003e;\u003c\/span\u003e      \n  \u003cb\u003e\u003cspan\u003eSerial\u003c\/span\u003e\u003c\/b\u003e\u003cspan\u003e.\u003c\/span\u003e\u003cspan\u003eprint\u003c\/span\u003e\u003cspan\u003e(\u003c\/span\u003e\u003cspan\u003eval_Digital\u003c\/span\u003e\u003cspan\u003e)\u003c\/span\u003e\u003cspan\u003e;\u003c\/span\u003e          \n                                             \u003cspan\u003e\/\/ Printout our alert level\u003c\/span\u003e\n  \u003cspan\u003eif\u003c\/span\u003e \u003cspan\u003e(\u003c\/span\u003e\u003cspan\u003eval_ADC\u003c\/span\u003e \u003cspan\u003e\u0026gt;=\u003c\/span\u003e \u003cspan\u003eGAS_ALERT\u003c\/span\u003e\u003cspan\u003e)\u003c\/span\u003e \u003cb\u003e\u003cspan\u003eSerial\u003c\/span\u003e\u003c\/b\u003e\u003cspan\u003e.\u003c\/span\u003e\u003cspan\u003eprintln\u003c\/span\u003e\u003cspan\u003e(\u003c\/span\u003e\u003cspan\u003e\"tGAS ALERT!\"\u003c\/span\u003e\u003cspan\u003e)\u003c\/span\u003e\u003cspan\u003e;\u003c\/span\u003e\n  \u003cspan\u003eelse\u003c\/span\u003e \u003cb\u003e\u003cspan\u003eSerial\u003c\/span\u003e\u003c\/b\u003e\u003cspan\u003e.\u003c\/span\u003e\u003cspan\u003eprintln\u003c\/span\u003e\u003cspan\u003e(\u003c\/span\u003e\u003cspan\u003e\"tReading below alert level\"\u003c\/span\u003e\u003cspan\u003e)\u003c\/span\u003e\u003cspan\u003e;\u003c\/span\u003e\n\n  \u003cspan\u003edelay\u003c\/span\u003e\u003cspan\u003e(\u003c\/span\u003e\u003cspan\u003e1000\u003c\/span\u003e\u003cspan\u003e)\u003c\/span\u003e\u003cspan\u003e;\u003c\/span\u003e      \u003cspan\u003e\/\/ Take a reading every second for test purposes.\u003c\/span\u003e\n\u003cspan\u003e}\u003c\/span\u003e\n\u003cbutton class=\"copy-the-code-button\" data-style=\"svg-icon\" title=\"Copy\"\u003e\u003csvg aria-hidden=\"true\" role=\"img\" class=\"copy-icon\" viewbox=\"0 0 16 16\" width=\"16\" height=\"16\" fill=\"currentColor\" focusable=\"false\"\u003e\u003cpath d=\"M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z\"\u003e\u003c\/path\u003e\u003cpath d=\"M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z\"\u003e\u003c\/path\u003e\u003c\/svg\u003e\u003c\/button\u003e\u003c\/pre\u003e\n\u003ch2\u003e\u003cstrong\u003eBEFORE THEY ARE SHIPPED, THESE MODULES ARE:\u003c\/strong\u003e\u003c\/h2\u003e\n\u003cul\u003e\n\u003cli\u003eSample tested per shipment\u003c\/li\u003e\n\u003c\/ul\u003e\n\u003cp\u003e\u003cem\u003eNotes: \u003c\/em\u003e\u003c\/p\u003e\n\u003col\u003e\n\u003cli\u003e\u003ci\u003eNone\u003c\/i\u003e\u003c\/li\u003e\n\u003c\/ol\u003e\n\u003chr\u003e\n\u003ch2\u003eTechnical Specifications\u003c\/h2\u003e\n\u003ctable class=\"table table-hover\" width=\"850\"\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd width=\"145\"\u003e \u003cstrong\u003eOperating Ratings\u003c\/strong\u003e\n\u003c\/td\u003e\n\u003ctd width=\"264\"\u003e\u003c\/td\u003e\n\u003ctd width=\"229\"\u003e\u003c\/td\u003e\n\u003c\/tr\u003e\n\u003ctr\u003e\n\u003ctd width=\"145\"\u003e        V\u003csub\u003ecc\u003c\/sub\u003e\n\u003c\/td\u003e\n\u003ctd width=\"264\"\u003e\u003c\/td\u003e\n\u003ctd width=\"229\"\u003e5V\u003c\/td\u003e\n\u003c\/tr\u003e\n\u003ctr\u003e\n\u003ctd width=\"145\"\u003e        I\u003csub\u003e(typ)\u003c\/sub\u003e\n\u003c\/td\u003e\n\u003ctd width=\"264\"\u003e\u003c\/td\u003e\n\u003ctd width=\"229\"\u003e150mA (typ)\u003c\/td\u003e\n\u003c\/tr\u003e\n\u003ctr\u003e\n\u003ctd width=\"145\"\u003e       V\u003csub\u003eout\u003c\/sub\u003e\n\u003c\/td\u003e\n\u003ctd width=\"264\"\u003e Analog Output\u003c\/td\u003e\n\u003ctd width=\"229\"\u003e 140mV to 4V (typ)\u003c\/td\u003e\n\u003c\/tr\u003e\n\u003ctr\u003e\n\u003ctd width=\"145\"\u003e       Sensor Output\u003c\/td\u003e\n\u003ctd width=\"264\"\u003e Measurement Range\u003c\/td\u003e\n\u003ctd width=\"229\"\u003e 300 ～ 10000 ppm(CH4)\u003c\/td\u003e\n\u003c\/tr\u003e\n\u003ctr\u003e\n\u003ctd width=\"145\"\u003e\u003cstrong\u003eDimensions\u003c\/strong\u003e\u003c\/td\u003e\n\u003ctd width=\"264\"\u003e\u003c\/td\u003e\n\u003ctd width=\"229\"\u003e\u003c\/td\u003e\n\u003c\/tr\u003e\n\u003ctr\u003e\n\u003ctd width=\"145\"\u003e      Sensor Probe Board\u003c\/td\u003e\n\u003ctd width=\"264\"\u003eL x W (PCB)\u003c\/td\u003e\n\u003ctd width=\"229\"\u003e32 x 20mm (1.26 x 0.8″)\u003c\/td\u003e\n\u003c\/tr\u003e\n\u003ctr\u003e\n\u003ctd width=\"145\"\u003e\u003cstrong\u003e Datasheet\u003c\/strong\u003e\u003c\/td\u003e\n\u003ctd width=\"264\"\u003e\u003c\/td\u003e\n\u003ctd width=\"229\"\u003e\u003ca href=\"https:\/\/cdn.sparkfun.com\/datasheets\/Sensors\/Biometric\/MQ-4%20Ver1.3%20-%20Manual.pdf\" rel=\"noopener\" target=\"_blank\"\u003e\u003cspan\u003e\u003cstrong\u003eMQ-4\u003c\/strong\u003e\u003c\/span\u003e\u003c\/a\u003e\u003c\/td\u003e\n\u003c\/tr\u003e\n\u003c\/tbody\u003e\n\u003c\/table\u003e\n\u003c!----\u003e","brand":"Keszoox","offers":[{"title":"Default Title","offer_id":45683534987499,"sku":"","price":7.37,"currency_code":"USD","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0677\/1005\/8731\/files\/MQ-4-Natural-Gas-Methane-Sensor-Module-1.jpg?v=1723005172","url":"https:\/\/keszooxstore.com\/products\/methane-gas-sensor-mq-4-module","provider":"Keszoox","version":"1.0","type":"link"}