{"id":2974,"date":"2020-02-24T00:48:16","date_gmt":"2020-02-23T15:48:16","guid":{"rendered":"https:\/\/programresource.net\/?p=2974"},"modified":"2020-02-24T00:48:25","modified_gmt":"2020-02-23T15:48:25","slug":"use-tiny-64x32-dot-oeld-display-with-arduino-esp","status":"publish","type":"post","link":"https:\/\/programresource.net\/en\/2020\/02\/24\/2974.html","title":{"rendered":"Use tiny 64&#215;32 dot OELD display with Arduino \/ ESP"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/programresource.net\/images\/2020\/02\/P_20200223_234135_vHDR_Auto.jpg\"><img decoding=\"async\" src=\"https:\/\/programresource.net\/images\/2020\/02\/P_20200223_234135_vHDR_Auto-1024x577.jpg\" alt=\"\" class=\"wp-image-2967\" srcset=\"https:\/\/programresource.net\/images\/2020\/02\/P_20200223_234135_vHDR_Auto-1024x577.jpg 1024w, https:\/\/programresource.net\/images\/2020\/02\/P_20200223_234135_vHDR_Auto-300x169.jpg 300w, https:\/\/programresource.net\/images\/2020\/02\/P_20200223_234135_vHDR_Auto-768x433.jpg 768w, https:\/\/programresource.net\/images\/2020\/02\/P_20200223_234135_vHDR_Auto.jpg 1391w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>There are many 128&#215;64 or 128&#215;32 monochrome OLED display out, and recently, I&#8217;ve seen tiny 64&#215;32 dot OLED display sold.<\/p>\n\n\n\n<p>However, library such as Adafruit SSD1306 does not support this resolution at this time. Either find library which support tiny display, or make modification to library.<\/p>\n\n\n\n<p>I&#8217;ve modifed Adafruit SSD1306 library (version 2.2.0) to use with 64&#215;32 OLED display.<\/p>\n\n\n\n<p>Modifications are 2 part in Adafruit_SSD1306.cpp file. Around line 549 and 888, add \/ modify for 64&#215;32 resolution. Since I simply replaced code near line 888, this library won&#8217;t be compatible with other resolution.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; first-line: 549; title: ; notranslate\" title=\"\">\n  if((WIDTH == 128) &amp;&amp; (HEIGHT == 32)) {\n    comPins = 0x02;\n    contrast = 0x8F;\n  } else if((WIDTH == 128) &amp;&amp; (HEIGHT == 64)) {\n    comPins = 0x12;\n    contrast = (vccstate == SSD1306_EXTERNALVCC) ? 0x9F : 0xCF;\n  } else if((WIDTH == 96) &amp;&amp; (HEIGHT == 16)) {\n    comPins = 0x2;    \/\/ ada x12\n    contrast = (vccstate == SSD1306_EXTERNALVCC) ? 0x10 : 0xAF;\n  } else if((WIDTH == 64) &amp;&amp; (HEIGHT == 32)) {\n    comPins = 0x12;\n    contrast = (vccstate == SSD1306_EXTERNALVCC) ? 0x9F : 0xCF;\n  } else {\n    \/\/ Other screen varieties -- TBD\n  }\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; first-line: 888; title: ; notranslate\" title=\"\">\nvoid Adafruit_SSD1306::display(void) {\n  TRANSACTION_START\n\/*  static const uint8_t PROGMEM dlist1&#91;] = {\n    SSD1306_PAGEADDR,\n    0,                         \/\/ Page start address\n    0xFF,                      \/\/ Page end (not really, but works here)\n    SSD1306_COLUMNADDR,\n    0 };                       \/\/ Column start address\n  ssd1306_commandList(dlist1, sizeof(dlist1));\n  ssd1306_command1(WIDTH - 1); \/\/ Column end address*\/\n  static const uint8_t PROGMEM dlist1&#91;] = {\n    SSD1306_PAGEADDR,\n    0,                         \/\/ Page start address\n    0xFF,                      \/\/ Page end (not really, but works here)\n    SSD1306_COLUMNADDR,\n    0x20 };                       \/\/ Column start address\n  ssd1306_commandList(dlist1, sizeof(dlist1));\n  ssd1306_command1(0x20 + (WIDTH - 1)); \/\/ Column end address\n\n<\/pre><\/div>\n\n\n<p>Simple Hello World sample sketch.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\n#include &lt;Wire.h&gt;\n#include &lt;SPI.h&gt;\n#include &lt;Adafruit_GFX.h&gt;\n#include &quot;Adafruit_SSD1306.h&quot;\n\n#define SCREEN_WIDTH 64 \/\/ OLED display width, in pixels\n#define SCREEN_HEIGHT 32 \/\/ OLED display height, in pixels\nAdafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &amp;Wire, -1);\n\nvoid setup() {\n\tWire.begin();\n\tdisplay.begin(SSD1306_SWITCHCAPVCC, 0x3C);  \/\/ initialize with the I2C addr\n\n\tdisplay.clearDisplay();\n\tdisplay.setTextSize(1);\n\tdisplay.setTextColor(WHITE);\n\tdisplay.setCursor(0, 5);\n\tdisplay.print(&quot;Hello\\n World&quot;);\n\tdisplay.display();\n}\n\nvoid loop() {\n\n}\n<\/pre><\/div>\n\n\n<p>Below includes sample sketch with modified library.<\/p>\n\n\n\n<div class=\"wp-block-file\"><a href=\"https:\/\/programresource.net\/images\/2020\/02\/oled_64x32.zip\">oled_64x32.zip<\/a><a href=\"https:\/\/programresource.net\/images\/2020\/02\/oled_64x32.zip\" class=\"wp-block-file__button\" download>\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/a><\/div>\n\n\n\n<p>Also, I&#8217;ve modified ESP_Adafruit_SSD1306 library to use with ESP8266.<\/p>\n\n\n\n<div class=\"wp-block-file\"><a href=\"https:\/\/programresource.net\/images\/2020\/02\/esp8266_oled64x32.zip\">esp8266_oled64x32.zip<\/a><a href=\"https:\/\/programresource.net\/images\/2020\/02\/esp8266_oled64x32.zip\" class=\"wp-block-file__button\" download>\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>There are many 128&#215;64 or 128&#215;32 monochrome OLED display out, and recently, I&#8217;ve seen tiny 64&#215;32 dot OLED display sold. However, library such as Adafruit SSD1306 does not support this resolution at this time. Either find library which support tiny display, or make modification to library. I&#8217;ve modifed Adafruit SSD1306 library (version 2.2.0) to use with 64&#215;32 OLED display. Modifications are 2 part in Adafruit_SSD1306.cpp file. Around line 549 and 888, add \/ modify for 64&#215;32 resolution. Since I simply replaced code near line 888, this library won&#8217;t be compatible with other resolution. Simple Hello World sample sketch. Below includes sample sketch with modified library. Also, I&#8217;ve modified ESP_Adafruit_SSD1306 library &#8230;<\/p>\n","protected":false},"author":2,"featured_media":2968,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[868],"tags":[862,904,894,895],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/programresource.net\/images\/2020\/02\/P_20200223_234135_vHDR_Auto.jpg","jetpack_shortlink":"https:\/\/wp.me\/p3pJyQ-LY","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/programresource.net\/en\/wp-json\/wp\/v2\/posts\/2974"}],"collection":[{"href":"https:\/\/programresource.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/programresource.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/programresource.net\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/programresource.net\/en\/wp-json\/wp\/v2\/comments?post=2974"}],"version-history":[{"count":1,"href":"https:\/\/programresource.net\/en\/wp-json\/wp\/v2\/posts\/2974\/revisions"}],"predecessor-version":[{"id":2975,"href":"https:\/\/programresource.net\/en\/wp-json\/wp\/v2\/posts\/2974\/revisions\/2975"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/programresource.net\/en\/wp-json\/wp\/v2\/media\/2968"}],"wp:attachment":[{"href":"https:\/\/programresource.net\/en\/wp-json\/wp\/v2\/media?parent=2974"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/programresource.net\/en\/wp-json\/wp\/v2\/categories?post=2974"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/programresource.net\/en\/wp-json\/wp\/v2\/tags?post=2974"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}