{"id":629,"date":"2018-01-20T11:20:25","date_gmt":"2018-01-20T10:20:25","guid":{"rendered":"http:\/\/stigern.net\/blog\/?p=629"},"modified":"2018-01-21T11:38:19","modified_gmt":"2018-01-21T10:38:19","slug":"wemos-d1-mini-oled-shield","status":"publish","type":"post","link":"https:\/\/stigern.net\/blog\/wemos-d1-mini-oled-shield\/","title":{"rendered":"Using Wemos D1 Mini &#038; Oled Shield"},"content":{"rendered":"<p><a href=\"https:\/\/stigern.net\/blog\/wp-content\/uploads\/2018\/01\/OledShield.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-630\" src=\"https:\/\/stigern.net\/blog\/wp-content\/uploads\/2018\/01\/OledShield-300x259.jpg\" alt=\"\" width=\"300\" height=\"259\" srcset=\"https:\/\/stigern.net\/blog\/wp-content\/uploads\/2018\/01\/OledShield-300x259.jpg 300w, https:\/\/stigern.net\/blog\/wp-content\/uploads\/2018\/01\/OledShield.jpg 700w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>In this guide I&#8217;ll show you how to use the shield and it&#8217;s two buttons. Lets get to it.<\/p>\n<p>Resoltion is 64&#215;48<br \/>\nButton A is by default pin D3.<br \/>\nButton B is by default pin D4.<\/p>\n<p>Buttons can be customized by soldering jumper pads under the shield.<\/p>\n<p><strong>Parts:<\/strong><\/p>\n<p><a href=\"https:\/\/www.aliexpress.com\/wholesale?catId=0&amp;initiative_id=SB_20180120011646&amp;SearchText=wemos+d1+mini\" target=\"_blank\" rel=\"noopener\">Wemos D1 Mini @ Aliexpress<\/a><\/p>\n<p><a href=\"https:\/\/www.aliexpress.com\/wholesale?catId=0&amp;initiative_id=SB_20180120020824&amp;SearchText=wemos+oled+shield\" target=\"_blank\" rel=\"noopener\">Oled Shield @ Aliexpress<\/a><\/p>\n<p>PS, be sure to get the shield with A &amp; B buttons when you buy it, there are a few types to choose from.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<p>There are several libraries to choose from, but I found the one from <a href=\"https:\/\/github.com\/sparkfun\/SparkFun_Micro_OLED_Arduino_Library\/tree\/V_1.0.0\" target=\"_blank\" rel=\"noopener\">Sparkfun<\/a> to be suitable for my use.<\/p>\n<p>Download it, then unzip in libraries folder and restart Arduino IDE. Then paste my code:<\/p>\n<p>[codesyntax lang=&#8221;c&#8221; lines=&#8221;no&#8221; title=&#8221;Example Code&#8221;]<\/p>\n<pre>#include &lt;Wire.h&gt;  \/\/ Include Wire if you're using I2C\r\n#include &lt;SFE_MicroOLED.h&gt;  \/\/ Include the SFE_MicroOLED library\r\n\r\n#define PIN_RESET 255  \/\/\r\n#define DC_JUMPER 0  \/\/ I2C Addres: 0 - 0x3C, 1 - 0x3D\r\n\r\nMicroOLED oled(PIN_RESET, DC_JUMPER); \/\/ Example I2C declaration\r\n\r\nvoid setup()\r\n{\r\n  \/\/ Before you can start using the OLED, call begin() to init\r\n  \/\/ all of the pins and configure the OLED.\r\n  oled.begin();\r\n  \/\/ clear(ALL) will clear out the OLED's graphic memory.\r\n  \/\/ clear(PAGE) will clear the Arduino's display buffer.\r\n  oled.clear(ALL);  \/\/ Clear the display's memory (gets rid of artifacts)\r\n\r\n  pinMode(D4, INPUT); \/\/ Setting D4 B Button as input\r\n  pinMode(D3, INPUT); \/\/ Setting D3 A Button as input\r\n}\r\n\r\nvoid loop()\r\n{\r\n  oled.clear(PAGE);     \/\/ Clear the screen\r\n  oled.setFontType(0);  \/\/ Set font to type 0\r\n  oled.setCursor(0, 0); \/\/ Set cursor to top-left\r\n  oled.print(\"Line 1\");\r\n  oled.setCursor(0, 8); \/\/ Set cursor to top-left\r\n  oled.print(\"Line 2\");\r\n  oled.setCursor(0, 16); \/\/ Set cursor to top-left\r\n  oled.print(\"Line 3\");\r\n  oled.setCursor(0, 24); \/\/ Set cursor to top-left\r\n  oled.print(\"Line 4\");\r\n  oled.setCursor(0, 32); \/\/ Set cursor to top-left\r\n  oled.print(\"Line 5\");\r\n  oled.setCursor(0, 40); \/\/ Set cursor to top-left\r\n  oled.print(\"Line 6\");\r\n\r\n\r\n  if (digitalRead(D4) == LOW)\r\n  {\r\n    oled.setCursor(0, 40); \/\/ Set cursor to top-left\r\n    oled.print(\"B Pushed\");\r\n\r\n  }\r\n\r\n  if (digitalRead(D3) == LOW)\r\n  {\r\n    oled.setCursor(0, 32); \/\/ Set cursor to top-left\r\n    oled.print(\"A Pushed\");\r\n\r\n  }\r\n  oled.display();\r\n}<\/pre>\n<p>[\/codesyntax]<\/p>\n<p>You should now see this when buttons are pressed:<\/p>\n<p><a href=\"https:\/\/stigern.net\/blog\/wp-content\/uploads\/2018\/01\/ShieldButtonTEst.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-632\" src=\"https:\/\/stigern.net\/blog\/wp-content\/uploads\/2018\/01\/ShieldButtonTEst-300x242.jpg\" alt=\"\" width=\"300\" height=\"242\" srcset=\"https:\/\/stigern.net\/blog\/wp-content\/uploads\/2018\/01\/ShieldButtonTEst-300x242.jpg 300w, https:\/\/stigern.net\/blog\/wp-content\/uploads\/2018\/01\/ShieldButtonTEst-768x618.jpg 768w, https:\/\/stigern.net\/blog\/wp-content\/uploads\/2018\/01\/ShieldButtonTEst.jpg 800w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Thats it! Now play around with it. Hope this short guide was helpful.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this guide I&#8217;ll show you how to use the shield and it&#8217;s two buttons. Lets get to it. Resoltion is 64&#215;48 Button A is by default pin D3. Button B is by default pin D4. Buttons can be customized by soldering jumper pads under the shield. Parts: Wemos D1 Mini @ Aliexpress Oled Shield [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,4],"tags":[16,140,368,45,369,367],"class_list":["post-629","post","type-post","status-publish","format-standard","hentry","category-arduino-electronics","category-electronics","tag-arduino","tag-electronics-2","tag-esp8266","tag-programming","tag-sht30","tag-wemos"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":8}},"_links":{"self":[{"href":"https:\/\/stigern.net\/blog\/wp-json\/wp\/v2\/posts\/629","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stigern.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stigern.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stigern.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/stigern.net\/blog\/wp-json\/wp\/v2\/comments?post=629"}],"version-history":[{"count":5,"href":"https:\/\/stigern.net\/blog\/wp-json\/wp\/v2\/posts\/629\/revisions"}],"predecessor-version":[{"id":637,"href":"https:\/\/stigern.net\/blog\/wp-json\/wp\/v2\/posts\/629\/revisions\/637"}],"wp:attachment":[{"href":"https:\/\/stigern.net\/blog\/wp-json\/wp\/v2\/media?parent=629"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stigern.net\/blog\/wp-json\/wp\/v2\/categories?post=629"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stigern.net\/blog\/wp-json\/wp\/v2\/tags?post=629"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}