{"id":1649,"date":"2018-07-04T13:13:54","date_gmt":"2018-07-04T20:13:54","guid":{"rendered":"http:\/\/www.donluc.com\/?p=1649"},"modified":"2018-07-04T13:13:54","modified_gmt":"2018-07-04T20:13:54","slug":"project-6-microview-alcohol-gas-sensor-mk09","status":"publish","type":"post","link":"https:\/\/www.donluc.com\/?p=1649","title":{"rendered":"Project #6: MicroView &#8211; Alcohol Gas Sensor &#8211; Mk09"},"content":{"rendered":"<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/07\/DonLuc1807Mk01a.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/07\/DonLuc1807Mk01a.png\" alt=\"\" width=\"720\" height=\"871\" class=\"alignnone size-full wp-image-1650\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/07\/DonLuc1807Mk01a.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/07\/DonLuc1807Mk01a-248x300.png 248w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/07\/DonLuc1807Mk01b.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/07\/DonLuc1807Mk01b.png\" alt=\"\" width=\"720\" height=\"449\" class=\"alignnone size-full wp-image-1651\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/07\/DonLuc1807Mk01b.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/07\/DonLuc1807Mk01b-300x187.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/07\/DonLuc1807Mk01c.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/07\/DonLuc1807Mk01c.png\" alt=\"\" width=\"720\" height=\"540\" class=\"alignnone size-full wp-image-1652\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/07\/DonLuc1807Mk01c.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/07\/DonLuc1807Mk01c-300x225.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/07\/DonLuc1807Mk01d.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/07\/DonLuc1807Mk01d.png\" alt=\"\" width=\"720\" height=\"405\" class=\"alignnone size-full wp-image-1653\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/07\/DonLuc1807Mk01d.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/07\/DonLuc1807Mk01d-300x169.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<div style=\"width: 720px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-1649-1\" width=\"720\" height=\"406\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/07\/DonLuc1807Mk01.mp4?_=1\" \/><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/07\/DonLuc1807Mk01.mp4\">https:\/\/www.donluc.com\/wp-content\/uploads\/2018\/07\/DonLuc1807Mk01.mp4<\/a><\/video><\/div>\n<p><strong>Alcohol Gas Sensor &#8211; MQ-3<\/strong><\/p>\n<p>This alcohol sensor is suitable for detecting alcohol concentration on your breath, just like your common breathalyzer. It has a high sensitivity and fast response time. Sensor provides an analog resistive output based on alcohol concentration. The drive circuit is very simple, all it needs is one resistor. A simple interface could be a 0-3.3V ADC.<\/p>\n<p><strong>Features<\/strong><\/p>\n<p>* 5V DC or AC circuit<br \/>\n* Requires heater voltage<br \/>\n* Operation Temperature: -10 to 70 degrees C<br \/>\n* Heater consumption: less than 750mW* 16.8mm diameter<br \/>\n* 9.3 mm height without the pins<\/p>\n<p><strong>Note:<\/strong> Again, the MQ-3 is heater-driven so be aware that the sensor will become warm and may even emit a smell at first. This is completely normal.<\/p>\n<p><strong>Calibration:<\/strong> If you take your time, you can find out what values equate to specific percentages or even blood alcohol concentration in the case of a breathalyzer. You will of course need to calibrate your MQ-3 based on your specific Arduino code since sensor readings will vary. Do not get the sensor wet with alcohol! Simply squeeze to breathe the vapors of the alcohol into the sensor and take your readings. <\/p>\n<p><strong>Alcohol Gas Sensor &#8211; MQ-3<\/strong><\/p>\n<p> 1 x MicroView<br \/>\n 1 x MicroView &#8211; USB Programmer<br \/>\n 1 x Alcohol Gas Sensor &#8211; MQ-3<br \/>\n 1 x NeoPixel Stick &#8211; 8 x 5050 RGB LED<br \/>\n 1 x LED Green<br \/>\n 1 x 10k Ohm<br \/>\n 1 x 100k Ohm Potentiometer<br \/>\n 1 x Potentiometer Knob<br \/>\n 1 x 4 Header<br \/>\n 2 x 2 Header<br \/>\n14 x Jumper Wires 3&#8243; M\/M<br \/>\n 1 x Half-Size Breadboard<br \/>\n 1 x Battery Holder 3xAAA with Cover and Switch<br \/>\n 3 x Battery AAA<\/p>\n<p><strong>MicroView<\/strong><\/p>\n<p>Pot  &#8211; PIN 05 &#8211; Analog A2<br \/>\nMQ-3 &#8211; PIN 07 &#8211; Analog A0<br \/>\nGND  &#8211; PIN 08 &#8211; GND<br \/>\nVIN  &#8211; PIN 15 &#8211; +5V<br \/>\nNEO  &#8211; PIN 12 &#8211; Digital 3<br \/>\nLEDG &#8211; PIN 11 &#8211; Digital 2<\/p>\n<p><strong>DonLuc1807Mk01<\/strong><\/p>\n<p><strong>DonLuc1807Mk01.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"default\" data-enlighter-title=\"DonLuc1807Mk01.ino\">\r\n\/\/ ***** Don Luc *****\r\n\/\/ Software Version Information\r\n\/\/ Project #6: MicroView - Alcohol Gas Sensor - MQ-3 - Mk09\r\n\/\/ 7.1\r\n\/\/ DonLuc1807Mk01 7-1\r\n\/\/ MicroView\r\n\/\/ Alcohol Gas Sensor - MQ-3\r\n\r\n\/\/ include the library code:\r\n#include &lt;MicroView.h&gt;\r\n#include &lt;Adafruit_NeoPixel.h&gt;\r\n\r\n\/\/ Alcohol Gas Sensor - MQ-3\r\nint mq3Pin0 = A0;                         \/\/ Connected to the output pin of MQ3 \r\nint mq3Value = 0;\r\n\r\n\/\/ NeoPixels\r\n#define PIN 3                             \/\/ On digital pin 3\r\n#define NUMPIXELS 8                       \/\/ NeoPixels NUMPIXELS = 8\r\nAdafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);\r\nint red = 0;                              \/\/ Red\r\nint green = 0;                            \/\/ Green\r\nint blue = 0;                             \/\/ Blue\r\nint iNeo = 0;                             \/\/ Neopix\r\nconst int iBriPin = A2;                   \/\/ Panel Mount 1K potentiometer Brightneed\r\nint iBri = 0;                             \/\/ Neopix Brightness\r\nint iBriMin = 1023;                       \/\/ Brightneed minimum sensor value\r\nint iBriMax = 0;                          \/\/ Brightneed maximum sensor value\r\n\r\n\/\/ LED\r\nint ledG = 1;                             \/\/ LED Green\r\n\r\nvoid loop() {\r\n  \r\n  \/\/ Alcohol Gas Sensor - MQ-3\r\n  \/\/ Give ample warmup time for readings to stabilize\r\n  isMQ3();\r\n\r\n  delay(100);\r\n  \r\n  uView.clear(PAGE);  \/\/ Erase the memory buffer, the OLED will be cleared\r\n  \r\n}\r\n<\/pre>\n<p><strong>getMQ3.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"default\" data-enlighter-title=\"getMQ3.ino\">\r\n\/\/ Alcohol Gas Sensor - MQ-3\r\nvoid isMQ3(){\r\n\r\n  \/\/ LEDs - Low\r\n  for(int z=0; z&lt;NUMPIXELS; z++){ \r\n     \/\/ Black\r\n     red = 0;                                 \/\/ Red\r\n     green = 0;                               \/\/ Green\r\n     blue = 0;                                \/\/ Blue\r\n     iNeo = z;                                \/\/ Neopix       \r\n     neopix(); \r\n  }\r\n    \r\n  \/\/ Probe\r\n  mq3Value = analogRead(mq3Pin0);              \/\/ Take a reading from the probe\r\n  \r\n  if( mq3Value &gt;= 1 ){                         \/\/ If the reading isn&#039;t zero, proceed\r\n    \r\n    if (mq3Value &gt; 1){                         \/\/ If the average is over 50 ...\r\n      \/\/ Green\r\n      red = 0;                                 \/\/ Red\r\n      green = 255;                             \/\/ Green\r\n      blue = 0;                                \/\/ Blue\r\n      iNeo = 0;                                \/\/ Neopix       \r\n      neopix();      \r\n    }\r\n    else{                                      \/\/ and if it&#039;s not ...\r\n      \/\/ Black\r\n      red = 0;                                 \/\/ Red\r\n      green = 0;                               \/\/ Green\r\n      blue = 0;                                \/\/ Blue\r\n      iNeo = 0;                                \/\/ Neopix        \r\n      neopix();      \r\n    }\r\n\r\n    if (mq3Value &gt; 250){                        \/\/ and so on ...\r\n      \/\/ Green\r\n      red = 0;                                 \/\/ Red\r\n      green = 255;                             \/\/ Green\r\n      blue = 0;                                \/\/ Blue\r\n      iNeo = 1;                                \/\/ Neopix       \r\n      neopix();\r\n    }\r\n    else{\r\n      \/\/ Black\r\n      red = 0;                                 \/\/ Red\r\n      green = 0;                               \/\/ Green\r\n      blue = 0;                                \/\/ Blue\r\n      iNeo = 1;                                \/\/ Neopix        \r\n      neopix(); \r\n    }\r\n\r\n    if (mq3Value &gt; 350){\r\n      \/\/ Green\r\n      red = 0;                                 \/\/ Red\r\n      green = 255;                             \/\/ Green\r\n      blue = 0;                                \/\/ Blue\r\n      iNeo = 2;                                \/\/ Neopix       \r\n      neopix();\r\n    }\r\n    else{\r\n      \/\/ Black\r\n      red = 0;                                 \/\/ Red\r\n      green = 0;                               \/\/ Green\r\n      blue = 0;                                \/\/ Blue\r\n      iNeo = 1;                                \/\/ Neopix        \r\n      neopix(); \r\n    }\r\n\r\n\r\n    if (mq3Value &gt; 500){\r\n      \/\/ Yellow\r\n      red = 255;                               \/\/ Red\r\n      green = 255;                             \/\/ Green\r\n      blue = 0;                                \/\/ Blue\r\n      iNeo = 3;                                \/\/ Neopix\r\n      neopix();\r\n    }\r\n    else{\r\n      \/\/ Black\r\n      red = 0;                                 \/\/ Red\r\n      green = 0;                               \/\/ Green\r\n      blue = 0;                                \/\/ Blue\r\n      iNeo = 3;                                \/\/ Neopix       \r\n      neopix(); \r\n    }\r\n\r\n    if (mq3Value &gt; 650){\r\n      \/\/ Yellow\r\n      red = 255;                               \/\/ Red\r\n      green = 255;                             \/\/ Green\r\n      blue = 0;                                \/\/ Blue\r\n      iNeo = 4;                                \/\/ Neopix      \r\n      neopix();\r\n    }\r\n    else{\r\n      \/\/ Black\r\n      red = 0;                                 \/\/ Red\r\n      green = 0;                               \/\/ Green\r\n      blue = 0;                                \/\/ Blue\r\n      iNeo = 4;                                \/\/ Neopix        \r\n      neopix(); \r\n    }\r\n\r\n    if (mq3Value &gt; 750){\r\n      \/\/ Yellow\r\n      red = 255;                               \/\/ Red\r\n      green = 255;                             \/\/ Green\r\n      blue = 0;                                \/\/ Blue\r\n      iNeo = 5;                                \/\/ Neopix  \r\n      neopix();\r\n    }\r\n    else{\r\n      \/\/ Black\r\n      red = 0;                                 \/\/ Red\r\n      green = 0;                               \/\/ Green\r\n      blue = 0;                                \/\/ Blue\r\n      iNeo = 5;                                \/\/ Neopix        \r\n      neopix(); \r\n    }\r\n\r\n    if (mq3Value &gt; 850){\r\n      \/\/ Red\r\n      red = 255;                               \/\/ Red\r\n      green = 0;                               \/\/ Green\r\n      blue = 0;                                \/\/ Blue\r\n      iNeo = 6;                                \/\/ Neopix       \r\n      neopix();\r\n    }\r\n    else{\r\n      \/\/ Black\r\n      red = 0;                                 \/\/ Red\r\n      green = 0;                               \/\/ Green\r\n      blue = 0;                                \/\/ Blue\r\n      iNeo = 6;                                \/\/ Neopix       \r\n      neopix();\r\n    }\r\n\r\n    if (mq3Value &gt; 950){\r\n      \/\/ Red\r\n      red = 255;                               \/\/ Red\r\n      green = 0;                               \/\/ Green\r\n      blue = 0;                                \/\/ Blue\r\n      iNeo = 7;                                \/\/ Neopix      \r\n      neopix();\r\n    }\r\n    else{\r\n      \/\/ Black\r\n      red = 0;                                 \/\/ Red\r\n      green = 0;                               \/\/ Green\r\n      blue = 0;                                \/\/ Blue\r\n      iNeo = 7;                                \/\/ Neopix        \r\n      neopix();\r\n    }\r\n\r\n  }\r\n  \r\n  uView.setFontType(0);  \/\/ Set font type 0: Numbers and letters. 10 characters per line (6 lines)\r\n\r\n  uView.setCursor(0,10); \/\/ Alcohol Gas Sensor\r\n  uView.print( &quot;Alcohol&quot; );\r\n  uView.setCursor(0,30); \/\/ Alcohol Gas Sensor\r\n  uView.print( mq3Value ); \r\n        \r\n  uView.display();       \/\/ Display\r\n   \r\n}\r\n<\/pre>\n<p><strong>neopix.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"default\" data-enlighter-title=\"neopix.ino\">\r\n\/\/ Neopix\r\nvoid neopix() { \r\n\r\n    \/\/ Brightness\r\n    iBri = analogRead(iBriPin);\r\n\r\n    \/\/ iBri apply the calibration to the sensor reading\r\n    iBri = map(iBri, iBriMin, iBriMax, 0, 255);\r\n\r\n    \/\/ iBri in case the sensor value is outside the range seen during calibration\r\n    iBri = constrain(iBri, 0, 255);  \r\n    \r\n    pixels.setBrightness( iBri );\r\n    \/\/ Pixels.Color takes RGB values, from 0,0,0 up to 255,255,255\r\n    pixels.setPixelColor( iNeo, pixels.Color(red,green,blue) ); \r\n    \/\/ This sends the updated pixel color to the hardware\r\n    pixels.show(); \r\n    \/\/ Delay for a period of time (in milliseconds)\r\n    delay(50);     \r\n  \r\n}\r\n<\/pre>\n<p><strong>setup.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"default\" data-enlighter-title=\"setup.ino\">\r\n\/\/ Setup\r\nvoid setup() {\r\n\r\n  uView.begin();           \/\/ Begin of MicroView\r\n  uView.clear(ALL);        \/\/ Erase hardware memory inside the OLED controller\r\n  uView.display();         \/\/ Display the content in the buffer memory, by default it is the MicroView logo\r\n  \r\n  delay(1000);\r\n  \r\n  uView.clear(PAGE);       \/\/ Erase the memory buffer, the OLED will be cleared.\r\n   \r\n  uView.setFontType(1);    \/\/ Set font type 1: Numbers and letters. 7 characters per line (3 lines)\r\n  uView.setCursor(0,20);\r\n  uView.print(&quot;Don Luc&quot;);  \/\/ Don Luc\r\n  uView.display();         \/\/ Display\r\n  \r\n  delay(5000);\r\n\r\n  uView.clear(PAGE);       \/\/ Erase the memory buffer, the OLED will be cleared.\r\n\r\n  uView.setFontType(1);    \/\/ Set font type 1: Numbers and letters. 7 characters per line (3 lines)\r\n  uView.setCursor(0,20);\r\n  uView.print(&quot;MQ-3&quot;);     \/\/ Alcohol Gas Sensor - MQ-3\r\n  uView.display();         \/\/ Display \r\n  \r\n  delay(5000);\r\n  \r\n  uView.clear(PAGE);       \/\/ Erase the memory buffer, the OLED will be cleared\r\n\r\n  \/\/ NeoPixels\r\n  pixels.begin();          \/\/ This initializes the NeoPixel library\r\n\r\n  \/\/ LED\r\n  pinMode( ledG, OUTPUT ); \/\/ LED Green \r\n  \/\/ LED Green - High \r\n  digitalWrite( ledG, HIGH);\r\n       \r\n}\r\n<\/pre>\n<p><strong>Don Luc<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Alcohol Gas Sensor &#8211; MQ-3 This alcohol sensor is suitable for detecting alcohol concentration on your breath, just like your common breathalyzer. It has a high sensitivity and fast response time. Sensor provides an analog resistive output based on alcohol concentration. The drive circuit is very simple, all it needs is one resistor. A simple &#8230; <a title=\"Project #6: MicroView &#8211; Alcohol Gas Sensor &#8211; Mk09\" class=\"read-more\" href=\"https:\/\/www.donluc.com\/?p=1649\" aria-label=\"Read more about Project #6: MicroView &#8211; Alcohol Gas Sensor &#8211; Mk09\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[70,50,38,59,5,58,10,43],"tags":[],"class_list":["post-1649","post","type-post","status-publish","format-standard","hentry","category-microview","category-arduino","category-digitalelectronics","category-fritzing","category-microcontrollers","category-arduino-programming","category-projects","category-sparkfun"],"_links":{"self":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/1649","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1649"}],"version-history":[{"count":4,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/1649\/revisions"}],"predecessor-version":[{"id":1658,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/1649\/revisions\/1658"}],"wp:attachment":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1649"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1649"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1649"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}