{"id":1511,"date":"2021-11-17T10:14:16","date_gmt":"2021-11-17T09:14:16","guid":{"rendered":"https:\/\/www.onetimenexttime.sk\/arduino\/?post_type=product&#038;p=1511"},"modified":"2024-02-22T19:38:16","modified_gmt":"2024-02-22T18:38:16","slug":"mq-4-methane-gas-sensor-natural-coal-co-methane-detector","status":"publish","type":"product","link":"https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/produkt\/mq-4-methane-gas-sensor-natural-coal-co-methane-detector\/","title":{"rendered":"MQ-4 Methane Gas Sensor Natural Coal Co Methane Detector"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h1>Informa\u010dn\u00e1 str\u00e1nka o senzore MQ-4<\/h1>\n<table>\n<tbody>\n<tr>\n<th>Popis<\/th>\n<td>Senzor MQ-4 je modul detektora met\u00e1nu, ktor\u00fd je schopn\u00fd detekova\u0165 pr\u00edrodn\u00fd plyn a uhlie plyn v ovzdu\u0161\u00ed.<\/td>\n<\/tr>\n<tr>\n<th>Vlastnosti<\/th>\n<td>\n<ul>\n<li>Detekcia met\u00e1nu<\/li>\n<li>Integrovate\u013enos\u0165 s r\u00f4znymi platformami<\/li>\n<li>Vysok\u00e1 citlivos\u0165<\/li>\n<li>N\u00edzka spotreba energie<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<th>\u0160pecifik\u00e1cie<\/th>\n<td>\n<ul>\n<li>Nap\u00e1jacie nap\u00e4tie: 5V<\/li>\n<li>Pracovn\u00e1 teplota: -10\u00b0C a\u017e 50\u00b0C<\/li>\n<li>Rozsah detekcie: 200ppm a\u017e 10 000ppm<\/li>\n<li>Rozhranie: Analogov\u00e9<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<th>Pr\u00edklady pou\u017eitia<\/th>\n<td>Senzor MQ-4 sa \u010dasto pou\u017e\u00edva na detekciu pr\u00edtomnosti met\u00e1nu v r\u00f4znych prostrediach, ako s\u00fa dom\u00e1cnosti, priemyseln\u00e9 z\u00e1vody a podzemn\u00e9 priestory.<\/td>\n<\/tr>\n<tr>\n<th>Pr\u00edkladov\u00fd k\u00f3d pre Arduino<\/th>\n<td class=\"code\">\n<pre>        \/\/ Importovanie kni\u017enice pre senzor MQ-4\r\n        #include &lt;MQ4.h&gt;\r\n        \r\n        \/\/ Defin\u00edcia pinu\r\n        int pinA0 = A0; \/\/ Anal\u00f3gov\u00fd pin\r\n        \r\n        \/\/ Inicializ\u00e1cia senzora\r\n        MQ4 mq4(pinA0);\r\n        \r\n        void setup() {\r\n          Serial.begin(9600); \/\/ Inicializ\u00e1cia komunik\u00e1cie s\u00e9riov\u00e9ho portu\r\n        }\r\n        \r\n        void loop() {\r\n          \/\/ \u010c\u00edtanie hodn\u00f4t z senzora\r\n          float ppm = mq4.read();\r\n          \r\n          \/\/ Vyp\u00edsanie hodn\u00f4t na s\u00e9riov\u00fd port\r\n          Serial.print(\"Hodnota met\u00e1nu (PPM): \");\r\n          Serial.println(ppm);\r\n          \r\n          delay(1000); \/\/ \u010cakanie 1 sekundu\r\n        }\r\n<\/pre>\n<\/td>\n<\/tr>\n<tr>\n<th>Pr\u00edkladov\u00fd k\u00f3d pre ESPHome<\/th>\n<td class=\"code\">\n<pre>        # Example configuration entry\r\n        sensor:\r\n          - platform: adc\r\n            pin: A0\r\n            name: \"Methane Sensor\"\r\n            update_interval: 30s\r\n            filters:\r\n              - lambda: return (pow(10, log10((0.12\/x)*(5-x)\/(5-0.12))\/(-0.35)))\r\n            unit_of_measurement: \"ppm\"\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><button>Skop\u00edrova\u0165 k\u00f3d<\/button><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h2>MQ-4 Met\u00e1nov\u00fd plynov\u00fd senzor Detektor pr\u00edrodn\u00e9ho uhlia a met\u00e1nu<\/h2>\n<p>&nbsp;<\/p>\n<p>MQ-4 je jedn\u00fdm z mnoh\u00fdch plynov\u00fdch senzorov pripraven\u00fdch na prepojenie s mikrokontrol\u00e9rmi. Rovnako ako ostatn\u00e9 senzory MQ, aj MQ-4 je najcitlivej\u0161\u00ed na konkr\u00e9tny plyn. Tentokr\u00e1t je to met\u00e1n, aj ke\u010f senzor st\u00e1le dok\u00e1\u017ee detekova\u0165 in\u00e9 hor\u013eav\u00e9 plyny, ako je but\u00e1n a prop\u00e1n.<\/p>\n<p>Preh\u013ead met\u00e1nov\u00e9ho sn\u00edma\u010da MQ-4<br \/>\nSrdcom MQ-4 je ohrieva\u010d a elektrochemick\u00fd senzor. Ke\u010f cie\u013eov\u00fd plyn vst\u00fapi do membr\u00e1ny a dosiahne senzor, podst\u00fapi redoxn\u00fa reakciu, ktor\u00e1 vytvor\u00ed pr\u00fad. Tento pr\u00fad je silnej\u0161\u00ed pre senzory pri \u0161pecifick\u00fdch plynoch. V pr\u00edpade MQ4 je citlivej\u0161\u00ed na met\u00e1n, but\u00e1n a prop\u00e1n.<\/p>\n<p>T\u00e1to breakout doska m\u00e1 \u0161tyri v\u00fdstupn\u00e9 kol\u00edky, a to A0, D0, GND a VCC.<\/p>\n<p>Nap\u00e1jacie kol\u00edky VCC a GND m\u00f4\u017eu by\u0165 pripojen\u00e9 priamo k 5 V kol\u00edku Arduina a GND.<\/p>\n<p>Pou\u017e\u00edvanie digit\u00e1lneho v\u00fdstupu<br \/>\nKol\u00edk D0 generuje vysok\u00e9 (rovnaj\u00face sa VCC) v pr\u00edtomnosti met\u00e1nu a n\u00edzke (rovnaj\u00face sa pribli\u017ene 0,1 V) inak. Tento \u201edigit\u00e1lny\u201c v\u00fdstup m\u00f4\u017eete kalibrova\u0165 pomocou trimovacieho hrnca na doske.<\/p>\n<p>Ak v\u00e1\u0161 projekt vy\u017eaduje iba detekciu met\u00e1nu, sta\u010d\u00ed pre\u010d\u00edta\u0165 pin D0. Tu je sch\u00e9ma zapojenia s Arduino UNO:<\/p>\n<p>&nbsp;<\/p>\n<p>T\u00e1to krivka je z \u00fadajov\u00e9ho listu zariadenia a ukazuje citlivos\u0165 MQ-4 na plyny. Ako je tu vidie\u0165, je najcitlivej\u0161\u00ed na CH4, chemick\u00fd n\u00e1zov met\u00e1nu. V krivke ch\u00fdbaj\u00fa prop\u00e1n a but\u00e1n, hoci oba s\u00fa zn\u00e1mymi zlo\u017ekami LPG (ktor\u00fd je v tejto krivke na druhom mieste po met\u00e1ne).<\/p>\n<p>Krivka je logaritmick\u00e1 stupnica a ukazuje vz\u0165ah medzi RS\/R0 a koncentr\u00e1ciou plynu v \u010dastiach na mili\u00f3n (PPM). RS\/R0 je pomer odporu sn\u00edma\u010da v cie\u013eovom plyne (RS) a odporu v \u010distom vzduchu (R0). Ak teda pozn\u00e1me RS\/R0, m\u00f4\u017eeme ur\u010di\u0165 koncentr\u00e1ciu plynu v PPM.<\/p>\n<p>Na odvodenie vzorca vezmeme dva body na tomto grafe. Tento vzorec sa potom nesk\u00f4r pou\u017eije v na\u0161om n\u00e1\u010drte Arduina.<\/p>\n<p>Najzrejmej\u0161\u00edm bodom je, ke\u010f RS\/R0 = 1 a PPM = 1000. Druh\u00fd bod je, ke\u010f je RS\/R0 niekde okolo 0,58 a PPM = 5000. Rovnica za\u010d\u00edna:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4696 tie-appear\" src=\"https:\/\/i0.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/log-point-slope.gif?resize=447%2C44\" alt=\"point-point-log equation\" width=\"447\" height=\"44\" data-attachment-id=\"4696\" data-permalink=\"https:\/\/www.teachmemicro.com\/mq-4-methane-gas-sensor-arduino\/log-point-slope\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/log-point-slope.gif?fit=447%2C44&amp;ssl=1\" data-orig-size=\"447,44\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"log-point-slope\" data-image-description=\"\" data-medium-file=\"https:\/\/i0.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/log-point-slope.gif?fit=300%2C30&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/log-point-slope.gif?fit=447%2C44&amp;ssl=1\" \/><\/p>\n<p>Tu prirad\u00edme Y1 = 1, X1 = 1000 z prv\u00e9ho bodu a Y2 = 0,58 a X2 = 5000 z druh\u00e9ho bodu. Nahraden\u00edm t\u00fdchto hodn\u00f4t vo vy\u0161\u0161ie uvedenej rovnici:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4697 tie-appear\" src=\"https:\/\/i0.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/log-point-eqn-1.gif?resize=248%2C19\" alt=\"Log point equation\" width=\"248\" height=\"19\" data-attachment-id=\"4697\" data-permalink=\"https:\/\/www.teachmemicro.com\/mq-4-methane-gas-sensor-arduino\/log-point-eqn-1\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/log-point-eqn-1.gif?fit=248%2C19&amp;ssl=1\" data-orig-size=\"248,19\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"log-point-eqn-1\" data-image-description=\"\" data-medium-file=\"https:\/\/i0.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/log-point-eqn-1.gif?fit=248%2C19&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/log-point-eqn-1.gif?fit=248%2C19&amp;ssl=1\" \/><\/p>\n<p>Zmena Y na RS\/R0 a X na PPM a rie\u0161enie pre PPM:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4698 tie-appear\" src=\"https:\/\/i1.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/ppm-formula-mq-4.gif?resize=180%2C40\" alt=\"MQ-4 methane gas PPM equation\" width=\"180\" height=\"40\" data-attachment-id=\"4698\" data-permalink=\"https:\/\/www.teachmemicro.com\/mq-4-methane-gas-sensor-arduino\/ppm-formula-mq-4\/\" data-orig-file=\"https:\/\/i1.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/ppm-formula-mq-4.gif?fit=180%2C40&amp;ssl=1\" data-orig-size=\"180,40\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"ppm-formula-mq-4\" data-image-description=\"\" data-medium-file=\"https:\/\/i1.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/ppm-formula-mq-4.gif?fit=180%2C40&amp;ssl=1\" data-large-file=\"https:\/\/i1.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/ppm-formula-mq-4.gif?fit=180%2C40&amp;ssl=1\" \/><\/p>\n<p>Teraz m\u00f4\u017eeme pou\u017ei\u0165 tento vzorec v na\u0161om n\u00e1\u010drte. Predt\u00fdm v\u0161ak mus\u00edme ur\u010di\u0165 pomer odporu RS\/R0.<\/p>\n<p>Arduino Sketch s met\u00e1nov\u00fdm v\u00fdstupom PPM<br \/>\nAko u\u017e bolo spomenut\u00e9, RS je odpor sn\u00edma\u010da v pr\u00edtomnosti met\u00e1nu, zatia\u013e \u010do R0 je odpor sn\u00edma\u010da v \u010distom vzduchu. Z t\u00fdchto dvoch by bolo jednoduch\u0161ie ur\u010di\u0165 R0. Odpor elektr\u00f3d 1-6 alebo 4-3 (pozri obr\u00e1zok ni\u017e\u0161ie) meriame pomocou ohmmetra.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4699 tie-appear\" src=\"https:\/\/i0.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/mq4-electrodes.png?resize=618%2C269\" sizes=\"(max-width: 618px) 100vw, 618px\" srcset=\"https:\/\/i0.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/mq4-electrodes.png?w=738&amp;ssl=1 738w, https:\/\/i0.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/mq4-electrodes.png?resize=300%2C130&amp;ssl=1 300w\" alt=\"Test points for sensor resistance\" width=\"618\" height=\"269\" data-attachment-id=\"4699\" data-permalink=\"https:\/\/www.teachmemicro.com\/mq-4-methane-gas-sensor-arduino\/mq4-electrodes\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/mq4-electrodes.png?fit=738%2C321&amp;ssl=1\" data-orig-size=\"738,321\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"mq4-electrodes\" data-image-description=\"\" data-medium-file=\"https:\/\/i0.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/mq4-electrodes.png?fit=300%2C130&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/mq4-electrodes.png?fit=618%2C269&amp;ssl=1\" \/><\/p>\n<p>My MQ-4 electrodes give out 945 ohms of resistance for both 1-6 and 4-3 electrodes. This means my R0 is 945 ohms.<\/p>\n<p>The value of RS would have to be known through a sketch. The MQ-4 breakout board uses this schematic:<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4700 tie-appear\" src=\"https:\/\/i1.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/mq-breakout-circuit-01.jpg?resize=618%2C298\" sizes=\"(max-width: 618px) 100vw, 618px\" srcset=\"https:\/\/i1.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/mq-breakout-circuit-01.jpg?w=667&amp;ssl=1 667w, https:\/\/i1.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/mq-breakout-circuit-01.jpg?resize=300%2C145&amp;ssl=1 300w\" alt=\"MQ-4 breakout circuit\" width=\"618\" height=\"298\" data-attachment-id=\"4700\" data-permalink=\"https:\/\/www.teachmemicro.com\/mq-4-methane-gas-sensor-arduino\/mq-breakout-circuit-01\/\" data-orig-file=\"https:\/\/i1.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/mq-breakout-circuit-01.jpg?fit=667%2C322&amp;ssl=1\" data-orig-size=\"667,322\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}\" data-image-title=\"mq breakout circuit-01\" data-image-description=\"\" data-medium-file=\"https:\/\/i1.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/mq-breakout-circuit-01.jpg?fit=300%2C145&amp;ssl=1\" data-large-file=\"https:\/\/i1.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/mq-breakout-circuit-01.jpg?fit=618%2C298&amp;ssl=1\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Ako vid\u00edte, Aout sa prip\u00e1ja k jednej z elektr\u00f3d a paralelne k odporu RL. To znamen\u00e1, \u017ee odpor elektr\u00f3dy vytv\u00e1ra deli\u010d nap\u00e4tia s RL a nap\u00e4tie na Aout je:<\/p>\n<p>Tu je RS na\u0161\u00edm cie\u013eov\u00fdm odporom elektr\u00f3dy, ktor\u00fd sa men\u00ed v z\u00e1vislosti od koncentr\u00e1cie met\u00e1nu.<\/p>\n<p>BTW, RL je SMD rezistor s ozna\u010den\u00edm 102. Tomu zodpoved\u00e1 odpor 1k.<\/p>\n<p>Tak\u017ee na z\u00edskanie RS pou\u017eijeme tento vzorec:<\/p>\n<p>N\u00e1\u010drt Arduina na ur\u010denie koncentr\u00e1cie met\u00e1nu v PPM je teraz:<\/p>\n<div id=\"crayon-6187bda7f1747643183451-1\" class=\"crayon-line\"><strong><span class=\"crayon-c\">MQ4 Sensor &#8211; Analog Output Example<\/span><\/strong><\/div>\n<p>&nbsp;<\/p>\n<div id=\"crayon-6187bda7f1747643183451-2\" style=\"padding-left: 80px;\">* Prints out methane concentration in PPM to serial monitor<\/div>\n<div id=\"crayon-6187bda7f1747643183451-3\" style=\"padding-left: 80px;\">* by R. Pelayo<\/div>\n<div id=\"crayon-6187bda7f1747643183451-4\" style=\"padding-left: 80px;\">*<\/div>\n<div id=\"crayon-6187bda7f1747643183451-5\" style=\"padding-left: 80px;\">* From TeachMeMicro (www.teachmemicro.com\/arduino-mq4-methane-sensor<\/div>\n<div id=\"crayon-6187bda7f1747643183451-6\" style=\"padding-left: 80px;\">*<\/div>\n<div id=\"crayon-6187bda7f1747643183451-7\" style=\"padding-left: 80px;\">* Date Created: 09\/11\/2020<\/div>\n<div id=\"crayon-6187bda7f1747643183451-8\" style=\"padding-left: 80px;\">*\/<\/div>\n<div id=\"crayon-6187bda7f1747643183451-9\" style=\"padding-left: 80px;\">const byte MQ4_Pin = A0; \/\/MQ4 A0 pin<\/div>\n<div id=\"crayon-6187bda7f1747643183451-10\" style=\"padding-left: 80px;\">const int R_0 = 945; \/\/Change this to your own R0 measurements<\/div>\n<div id=\"crayon-6187bda7f1747643183451-11\" style=\"padding-left: 80px;\"><\/div>\n<div id=\"crayon-6187bda7f1747643183451-12\" style=\"padding-left: 80px;\">void setup() {<\/div>\n<div id=\"crayon-6187bda7f1747643183451-13\" style=\"padding-left: 80px;\">\u00a0\u00a0 Serial.begin(9600);<\/div>\n<div id=\"crayon-6187bda7f1747643183451-14\" style=\"padding-left: 80px;\">}<\/div>\n<div id=\"crayon-6187bda7f1747643183451-15\" style=\"padding-left: 80px;\"><\/div>\n<div id=\"crayon-6187bda7f1747643183451-16\" style=\"padding-left: 80px;\">void loop() {<\/div>\n<div id=\"crayon-6187bda7f1747643183451-17\" style=\"padding-left: 80px;\">\u00a0\u00a0 Serial.println(getMethanePPM());<\/div>\n<div id=\"crayon-6187bda7f1747643183451-18\" style=\"padding-left: 80px;\">}<\/div>\n<div id=\"crayon-6187bda7f1747643183451-19\" style=\"padding-left: 80px;\"><\/div>\n<div id=\"crayon-6187bda7f1747643183451-20\" style=\"padding-left: 80px;\">\/*<\/div>\n<div id=\"crayon-6187bda7f1747643183451-21\" style=\"padding-left: 80px;\">* getMethanePPM returns a float value in PPM of methane concentration<\/div>\n<div id=\"crayon-6187bda7f1747643183451-22\" style=\"padding-left: 80px;\">*\/<\/div>\n<div id=\"crayon-6187bda7f1747643183451-23\" style=\"padding-left: 80px;\">float getMethanePPM(){<\/div>\n<div id=\"crayon-6187bda7f1747643183451-24\" style=\"padding-left: 80px;\">\u00a0\u00a0 float a0 = analogRead(A0); \/\/ get raw reading from sensor<\/div>\n<div id=\"crayon-6187bda7f1747643183451-25\" style=\"padding-left: 80px;\">\u00a0\u00a0 float v_o = a0 * 5 \/ 1023; \/\/ convert reading to volts<\/div>\n<div id=\"crayon-6187bda7f1747643183451-26\" style=\"padding-left: 80px;\">\u00a0\u00a0 float R_S = (5-v_o) * 1000 \/ v_o; \/\/ apply formula for getting RS<\/div>\n<div id=\"crayon-6187bda7f1747643183451-27\" style=\"padding-left: 80px;\">\u00a0\u00a0 float PPM = pow(R_S\/R_0,-2.95) * 1000; \/\/apply formula for getting PPM<\/div>\n<div id=\"crayon-6187bda7f1747643183451-28\" style=\"padding-left: 80px;\">\u00a0\u00a0 return PPM; \/\/ return PPM value to calling function<\/div>\n<div id=\"crayon-6187bda7f1747643183451-29\" style=\"padding-left: 80px;\">}<\/div>\n<p><!--more--><\/p>\n<p>To s\u00fa dva sp\u00f4soby pou\u017eitia met\u00e1nov\u00e9ho senzora MQ-4. Upozor\u0148ujeme, \u017ee tento n\u00e1\u010drt sl\u00fa\u017ei len na zobrazenie koncentr\u00e1ci\u00ed met\u00e1nu, nie but\u00e1nu alebo prop\u00e1nu. V pr\u00edpade ak\u00fdchko\u013evek ot\u00e1zok, reakci\u00ed alebo n\u00e1vrhov nap\u00ed\u0161te koment\u00e1r ni\u017e\u0161ie.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-4694 tie-appear alignleft\" src=\"https:\/\/i1.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/arduino-mq4-digital.jpg?resize=618%2C412\" sizes=\"(max-width: 618px) 100vw, 618px\" srcset=\"https:\/\/i1.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/arduino-mq4-digital.jpg?w=779&amp;ssl=1 779w, https:\/\/i1.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/arduino-mq4-digital.jpg?resize=300%2C200&amp;ssl=1 300w, https:\/\/i1.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/arduino-mq4-digital.jpg?resize=768%2C512&amp;ssl=1 768w\" alt=\"Arduino MQ-4 Digital Output\" width=\"618\" height=\"412\" data-attachment-id=\"4694\" data-permalink=\"https:\/\/www.teachmemicro.com\/mq-4-methane-gas-sensor-arduino\/arduino-mq4-digital\/\" data-orig-file=\"https:\/\/i1.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/arduino-mq4-digital.jpg?fit=779%2C519&amp;ssl=1\" data-orig-size=\"779,519\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}\" data-image-title=\"arduino-mq4-digital\" data-image-description=\"\" data-medium-file=\"https:\/\/i1.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/arduino-mq4-digital.jpg?fit=300%2C200&amp;ssl=1\" data-large-file=\"https:\/\/i1.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/arduino-mq4-digital.jpg?fit=618%2C412&amp;ssl=1\" \/><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-4693 tie-appear alignleft\" src=\"https:\/\/i0.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/mq-4-pinout.jpg?resize=344%2C562\" sizes=\"(max-width: 344px) 100vw, 344px\" srcset=\"https:\/\/i0.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/mq-4-pinout.jpg?w=344&amp;ssl=1 344w, https:\/\/i0.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/mq-4-pinout.jpg?resize=184%2C300&amp;ssl=1 184w\" alt=\"MQ-4 Pinout\" width=\"175\" height=\"286\" data-attachment-id=\"4693\" data-permalink=\"https:\/\/www.teachmemicro.com\/mq-4-methane-gas-sensor-arduino\/mq-4-pinout\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/mq-4-pinout.jpg?fit=344%2C562&amp;ssl=1\" data-orig-size=\"344,562\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}\" data-image-title=\"mq-4 pinout\" data-image-description=\"\" data-medium-file=\"https:\/\/i0.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/mq-4-pinout.jpg?fit=184%2C300&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/www.teachmemicro.com\/wp-content\/uploads\/2020\/09\/mq-4-pinout.jpg?fit=344%2C562&amp;ssl=1\" \/><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; &nbsp; Informa\u010dn\u00e1 str\u00e1nka o senzore MQ-4 Popis Senzor MQ-4 je modul detektora met\u00e1nu, ktor\u00fd je schopn\u00fd detekova\u0165 pr\u00edrodn\u00fd plyn&hellip;<\/p>\n","protected":false},"featured_media":1512,"template":"","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"product_cat":[16,76,69],"product_tag":[],"class_list":{"0":"post-1511","1":"product","2":"type-product","3":"status-publish","4":"has-post-thumbnail","6":"product_cat-ard","7":"product_cat-gas","8":"product_cat-sensors","10":"first","11":"instock","12":"shipping-taxable","13":"purchasable","14":"product-type-simple"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>MQ-4 Methane Gas Sensor Natural Coal Co Methane Detector - Arduino e-shop<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/produkt\/mq-4-methane-gas-sensor-natural-coal-co-methane-detector\/\" \/>\n<meta property=\"og:locale\" content=\"sk_SK\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MQ-4 Methane Gas Sensor Natural Coal Co Methane Detector - Arduino e-shop\" \/>\n<meta property=\"og:description\" content=\"&nbsp; &nbsp; Informa\u010dn\u00e1 str\u00e1nka o senzore MQ-4 Popis Senzor MQ-4 je modul detektora met\u00e1nu, ktor\u00fd je schopn\u00fd detekova\u0165 pr\u00edrodn\u00fd plyn&hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/produkt\/mq-4-methane-gas-sensor-natural-coal-co-methane-detector\/\" \/>\n<meta property=\"og:site_name\" content=\"Arduino e-shop\" \/>\n<meta property=\"article:modified_time\" content=\"2024-02-22T18:38:16+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.onetimenexttime.sk\/arduino\/wp-content\/uploads\/2021\/11\/17941.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"490\" \/>\n\t<meta property=\"og:image:height\" content=\"493\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Predpokladan\u00fd \u010das \u010d\u00edtania\" \/>\n\t<meta name=\"twitter:data1\" content=\"6 min\u00fat\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/produkt\/mq-4-methane-gas-sensor-natural-coal-co-methane-detector\/\",\"url\":\"https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/produkt\/mq-4-methane-gas-sensor-natural-coal-co-methane-detector\/\",\"name\":\"MQ-4 Methane Gas Sensor Natural Coal Co Methane Detector - Arduino e-shop\",\"isPartOf\":{\"@id\":\"https:\/\/www.onetimenexttime.sk\/arduino\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/produkt\/mq-4-methane-gas-sensor-natural-coal-co-methane-detector\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/produkt\/mq-4-methane-gas-sensor-natural-coal-co-methane-detector\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.onetimenexttime.sk\/arduino\/wp-content\/uploads\/2021\/11\/17941.jpg\",\"datePublished\":\"2021-11-17T09:14:16+00:00\",\"dateModified\":\"2024-02-22T18:38:16+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/produkt\/mq-4-methane-gas-sensor-natural-coal-co-methane-detector\/#breadcrumb\"},\"inLanguage\":\"sk-SK\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/produkt\/mq-4-methane-gas-sensor-natural-coal-co-methane-detector\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"sk-SK\",\"@id\":\"https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/produkt\/mq-4-methane-gas-sensor-natural-coal-co-methane-detector\/#primaryimage\",\"url\":\"https:\/\/www.onetimenexttime.sk\/arduino\/wp-content\/uploads\/2021\/11\/17941.jpg\",\"contentUrl\":\"https:\/\/www.onetimenexttime.sk\/arduino\/wp-content\/uploads\/2021\/11\/17941.jpg\",\"width\":490,\"height\":493},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/produkt\/mq-4-methane-gas-sensor-natural-coal-co-methane-detector\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Domov\",\"item\":\"https:\/\/www.onetimenexttime.sk\/arduino\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Obchod\",\"item\":\"https:\/\/www.onetimenexttime.sk\/arduino\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"MQ-4 Methane Gas Sensor Natural Coal Co Methane Detector\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.onetimenexttime.sk\/arduino\/#website\",\"url\":\"https:\/\/www.onetimenexttime.sk\/arduino\/\",\"name\":\"Arduino e-shop\",\"description\":\"Home Assistant\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.onetimenexttime.sk\/arduino\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"sk-SK\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MQ-4 Methane Gas Sensor Natural Coal Co Methane Detector - Arduino e-shop","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/produkt\/mq-4-methane-gas-sensor-natural-coal-co-methane-detector\/","og_locale":"sk_SK","og_type":"article","og_title":"MQ-4 Methane Gas Sensor Natural Coal Co Methane Detector - Arduino e-shop","og_description":"&nbsp; &nbsp; Informa\u010dn\u00e1 str\u00e1nka o senzore MQ-4 Popis Senzor MQ-4 je modul detektora met\u00e1nu, ktor\u00fd je schopn\u00fd detekova\u0165 pr\u00edrodn\u00fd plyn&hellip;","og_url":"https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/produkt\/mq-4-methane-gas-sensor-natural-coal-co-methane-detector\/","og_site_name":"Arduino e-shop","article_modified_time":"2024-02-22T18:38:16+00:00","og_image":[{"width":490,"height":493,"url":"https:\/\/www.onetimenexttime.sk\/arduino\/wp-content\/uploads\/2021\/11\/17941.jpg","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_misc":{"Predpokladan\u00fd \u010das \u010d\u00edtania":"6 min\u00fat"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/produkt\/mq-4-methane-gas-sensor-natural-coal-co-methane-detector\/","url":"https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/produkt\/mq-4-methane-gas-sensor-natural-coal-co-methane-detector\/","name":"MQ-4 Methane Gas Sensor Natural Coal Co Methane Detector - Arduino e-shop","isPartOf":{"@id":"https:\/\/www.onetimenexttime.sk\/arduino\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/produkt\/mq-4-methane-gas-sensor-natural-coal-co-methane-detector\/#primaryimage"},"image":{"@id":"https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/produkt\/mq-4-methane-gas-sensor-natural-coal-co-methane-detector\/#primaryimage"},"thumbnailUrl":"https:\/\/www.onetimenexttime.sk\/arduino\/wp-content\/uploads\/2021\/11\/17941.jpg","datePublished":"2021-11-17T09:14:16+00:00","dateModified":"2024-02-22T18:38:16+00:00","breadcrumb":{"@id":"https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/produkt\/mq-4-methane-gas-sensor-natural-coal-co-methane-detector\/#breadcrumb"},"inLanguage":"sk-SK","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/produkt\/mq-4-methane-gas-sensor-natural-coal-co-methane-detector\/"]}]},{"@type":"ImageObject","inLanguage":"sk-SK","@id":"https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/produkt\/mq-4-methane-gas-sensor-natural-coal-co-methane-detector\/#primaryimage","url":"https:\/\/www.onetimenexttime.sk\/arduino\/wp-content\/uploads\/2021\/11\/17941.jpg","contentUrl":"https:\/\/www.onetimenexttime.sk\/arduino\/wp-content\/uploads\/2021\/11\/17941.jpg","width":490,"height":493},{"@type":"BreadcrumbList","@id":"https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/produkt\/mq-4-methane-gas-sensor-natural-coal-co-methane-detector\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Domov","item":"https:\/\/www.onetimenexttime.sk\/arduino\/"},{"@type":"ListItem","position":2,"name":"Obchod","item":"https:\/\/www.onetimenexttime.sk\/arduino\/"},{"@type":"ListItem","position":3,"name":"MQ-4 Methane Gas Sensor Natural Coal Co Methane Detector"}]},{"@type":"WebSite","@id":"https:\/\/www.onetimenexttime.sk\/arduino\/#website","url":"https:\/\/www.onetimenexttime.sk\/arduino\/","name":"Arduino e-shop","description":"Home Assistant","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.onetimenexttime.sk\/arduino\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"sk-SK"}]}},"_links":{"self":[{"href":"https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/wp-json\/wp\/v2\/product\/1511"}],"collection":[{"href":"https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/wp-json\/wp\/v2\/product"}],"about":[{"href":"https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/wp-json\/wp\/v2\/types\/product"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/wp-json\/wp\/v2\/media\/1512"}],"wp:attachment":[{"href":"https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/wp-json\/wp\/v2\/media?parent=1511"}],"wp:term":[{"taxonomy":"product_cat","embeddable":true,"href":"https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/wp-json\/wp\/v2\/product_cat?post=1511"},{"taxonomy":"product_tag","embeddable":true,"href":"https:\/\/www.onetimenexttime.sk\/arduino\/index.php\/wp-json\/wp\/v2\/product_tag?post=1511"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}