{"id":1609,"date":"2016-11-28T06:26:38","date_gmt":"2016-11-28T13:26:38","guid":{"rendered":"http:\/\/play.fallows.ca\/wp\/?p=1609"},"modified":"2017-02-09T20:44:48","modified_gmt":"2017-02-10T03:44:48","slug":"nodemcu-i2c-lcd-display-saves-pins","status":"publish","type":"post","link":"https:\/\/play.fallows.ca\/wp\/projects\/electronics-projects\/nodemcu-i2c-lcd-display-saves-pins\/","title":{"rendered":"NodeMCU I2C LCD Display Saves Pins"},"content":{"rendered":"<p><a href=\"https:\/\/i0.wp.com\/play.fallows.ca\/wp\/wp-content\/uploads\/sites\/4\/2016\/11\/NodeMCU-I2C-LCD.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1610\" src=\"https:\/\/i0.wp.com\/play.fallows.ca\/wp\/wp-content\/uploads\/sites\/4\/2016\/11\/NodeMCU-I2C-LCD.jpg?resize=618%2C324\" alt=\"nodemcu i2c lcd\" width=\"618\" height=\"324\" srcset=\"https:\/\/i0.wp.com\/play.fallows.ca\/wp\/wp-content\/uploads\/sites\/4\/2016\/11\/NodeMCU-I2C-LCD.jpg?w=618&amp;ssl=1 618w, https:\/\/i0.wp.com\/play.fallows.ca\/wp\/wp-content\/uploads\/sites\/4\/2016\/11\/NodeMCU-I2C-LCD.jpg?resize=300%2C157&amp;ssl=1 300w\" sizes=\"auto, (max-width: 618px) 100vw, 618px\" \/><\/a><\/p>\n<p>My NodeMCU I2C LCD Display finally arrived. It works great and saves pins on the ESP-12E board.<!--more--><\/p>\n<p>Compared to the Arduino, NodeMCU V1.0 board has limited input\/output pins. One of the ways to make the best of this board is to use the I2C bus for communicating with peripherals. An LCD display board with a piggyback I2C module is available. This display only needs two control lines or GPIO pins on the NodeMCU. These lines are for data and clock signals, respectively. The piggyback module converts serial data on the I2C bus to control eight digital pins on the LCD module. The whole arrangement is <a href=\"http:\/\/www.ebay.ca\/itm\/IIC-I2C-TWI-SP-I-Serial-Interface1602-16X2-Character-LCD-Module-Display-Yellow-\/252513792517?hash=item3acafeb205:g:sUQAAOSwu4BVk1Gj\" target=\"_blank\" rel=\"nofollow\">available on E-Bay<\/a> for just over $2.<\/p>\n<p>There are four things needed to get up and running.<\/p>\n<ul>\n<li>Download and install the <a href=\"https:\/\/github.com\/marcoschwartz\/LiquidCrystal_I2C\" target=\"_blank\" rel=\"nofollow\">LiquidCrystal_I2C library<\/a> from Marco Schwartz.<\/li>\n<li>Figure out the I2C address for your LCD. It is usually either 0x27 or 0x3F. Here is a good <a href=\"http:\/\/arduino-info.wikispaces.com\/LCD-Blue-I2C#v1\" target=\"_blank\" rel=\"nofollow\">reference site<\/a> for these devices.<\/li>\n<li>Hook up the LCD SCL line to NodeMCU pin D1 and the SDA line to pin D2. Also provide the LCD with five volts.<\/li>\n<li>Write some Arduino code.<\/li>\n<\/ul>\n<pre class=\"brush: cpp; title: ; wrap-lines: false; notranslate\" title=\"\">\r\n#include &lt;LiquidCrystal_I2C.h&gt;\r\n\/*\r\n * Test program NodeMCU and YwRobot LCD 1602\r\n * Default I2C Pin SCL=D1 SDA=D2\r\n * Library modified with overloaded init() to\r\n * enable alternative I2C pin use\r\n *\/\r\n\r\n#define LCD_ADDRESS 0x3F\r\n#define NEW_SDA D3\r\n#define NEW_SCL D4\r\n#define USE_NEW_I2C\r\n\r\nLiquidCrystal_I2C lcd(LCD_ADDRESS,16,2);\r\n\r\nvoid setup() {\r\n#ifdef USE_NEW_I2C\r\n lcd.init(NEW_SDA, NEW_SCL);\r\n#else\r\n lcd.init();\r\n#endif\r\n lcd.backlight();\r\n lcd.setCursor(5,0);\r\n lcd.print(&quot;VE6EY&quot;);\r\n lcd.setCursor(3,1);\r\n lcd.print(&quot;Making It Up&quot;);\r\n}\r\n<\/pre>\n<h2>NodeMCU I2C LCD Display Library Modifications<\/h2>\n<p>By default,\u00a0the NodeMCU uses pins D1 and D2 for I2C serial communications. You might want to switch this to another set of pins. You can run the I2C bus on any two of D1 through D8, but not D0. Unfortunately, the LiquidCrystal_I2C library is hard wired to the defaults.<\/p>\n<p>But changing this is easy. First you create a second (overloaded) initialization function for the library. Second, you change one line of code, as follows.<\/p>\n<pre class=\"brush: cpp; title: ; wrap-lines: false; notranslate\" title=\"\">\r\n\/* Modifications to LiquidCrystal_I2C.h *\/\r\npublic:\r\n  void init();\r\n  void init(uint8_t sda, uint8_t scl);\/\/added\r\n\r\n\r\n\/* Modifications to LiquidCrystal_I2C.cpp *\/\r\nvoid LiquidCrystal_I2C::init(){\r\n\tWire.begin(); \/\/moved from init_priv\r\n\tinit_priv();\r\n}\r\n\r\nvoid LiquidCrystal_I2C::init(uint8_t sda, uint8_t scl){\r\n\tWire.begin(sda, scl); \/\/moved from init_priv\r\n\tinit_priv();\r\n}\r\n<\/pre>\n<p>With these changes, you can run your NodeMCU I2C LCD display off any of the GPIO pins except D0. Or just use the original init() function for the default pins.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My NodeMCU I2C LCD Display finally arrived. It works great and saves pins on the ESP-12E board.<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","_share_on_mastodon":"0"},"categories":[11],"tags":[52,215,214],"series":[261],"class_list":["post-1609","post","type-post","status-publish","format-standard","hentry","category-electronics-projects","tag-arduino","tag-esp-12e","tag-nodemcu","series-nodemcu"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>NodeMCU I2C LCD Display Saves Pins - Making It Up<\/title>\n<meta name=\"description\" content=\"Here&#039;s how to hook up the NodeMCU I2C LCD Display, and modify the library to run I2C on any of your GPIO pins D1 through D8.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/play.fallows.ca\/wp\/projects\/electronics-projects\/nodemcu-i2c-lcd-display-saves-pins\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"NodeMCU I2C LCD Display Saves Pins - Making It Up\" \/>\n<meta property=\"og:description\" content=\"Here&#039;s how to hook up the NodeMCU I2C LCD Display, and modify the library to run I2C on any of your GPIO pins D1 through D8.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/play.fallows.ca\/wp\/projects\/electronics-projects\/nodemcu-i2c-lcd-display-saves-pins\/\" \/>\n<meta property=\"og:site_name\" content=\"Making It Up\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/john.fallows.5\" \/>\n<meta property=\"article:published_time\" content=\"2016-11-28T13:26:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-02-10T03:44:48+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/play.fallows.ca\/wp\/wp-content\/uploads\/sites\/4\/2016\/11\/NodeMCU-I2C-LCD.jpg\" \/>\n<meta name=\"author\" content=\"John VE6EY\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@VE6EY\" \/>\n<meta name=\"twitter:site\" content=\"@VE6EY\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"John VE6EY\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/play.fallows.ca\/wp\/projects\/electronics-projects\/nodemcu-i2c-lcd-display-saves-pins\/\",\"url\":\"https:\/\/play.fallows.ca\/wp\/projects\/electronics-projects\/nodemcu-i2c-lcd-display-saves-pins\/\",\"name\":\"NodeMCU I2C LCD Display Saves Pins - Making It Up\",\"isPartOf\":{\"@id\":\"https:\/\/play.fallows.ca\/wp\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/play.fallows.ca\/wp\/projects\/electronics-projects\/nodemcu-i2c-lcd-display-saves-pins\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/play.fallows.ca\/wp\/projects\/electronics-projects\/nodemcu-i2c-lcd-display-saves-pins\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/play.fallows.ca\/wp\/wp-content\/uploads\/sites\/4\/2016\/11\/NodeMCU-I2C-LCD.jpg\",\"datePublished\":\"2016-11-28T13:26:38+00:00\",\"dateModified\":\"2017-02-10T03:44:48+00:00\",\"author\":{\"@id\":\"https:\/\/play.fallows.ca\/wp\/#\/schema\/person\/9750e0ab227030255d9806757525f945\"},\"description\":\"Here's how to hook up the NodeMCU I2C LCD Display, and modify the library to run I2C on any of your GPIO pins D1 through D8.\",\"breadcrumb\":{\"@id\":\"https:\/\/play.fallows.ca\/wp\/projects\/electronics-projects\/nodemcu-i2c-lcd-display-saves-pins\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/play.fallows.ca\/wp\/projects\/electronics-projects\/nodemcu-i2c-lcd-display-saves-pins\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/play.fallows.ca\/wp\/projects\/electronics-projects\/nodemcu-i2c-lcd-display-saves-pins\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/play.fallows.ca\/wp\/wp-content\/uploads\/sites\/4\/2016\/11\/NodeMCU-I2C-LCD.jpg?fit=618%2C324&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/play.fallows.ca\/wp\/wp-content\/uploads\/sites\/4\/2016\/11\/NodeMCU-I2C-LCD.jpg?fit=618%2C324&ssl=1\",\"width\":618,\"height\":324,\"caption\":\"nodemcu i2c lcd\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/play.fallows.ca\/wp\/projects\/electronics-projects\/nodemcu-i2c-lcd-display-saves-pins\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/play.fallows.ca\/wp\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Projects\",\"item\":\"https:\/\/play.fallows.ca\/wp\/category\/projects\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Electronics Projects\",\"item\":\"https:\/\/play.fallows.ca\/wp\/category\/projects\/electronics-projects\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"NodeMCU I2C LCD Display Saves Pins\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/play.fallows.ca\/wp\/#website\",\"url\":\"https:\/\/play.fallows.ca\/wp\/\",\"name\":\"Making It Up\",\"description\":\"Enjoying Radio and Maker Hobbies\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/play.fallows.ca\/wp\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/play.fallows.ca\/wp\/#\/schema\/person\/9750e0ab227030255d9806757525f945\",\"name\":\"John VE6EY\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/play.fallows.ca\/wp\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e4048edfe09efff51033c48b4fb951e8ac0a4dc84a25c96b25e5ae9f5b7069a5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e4048edfe09efff51033c48b4fb951e8ac0a4dc84a25c96b25e5ae9f5b7069a5?s=96&d=mm&r=g\",\"caption\":\"John VE6EY\"},\"sameAs\":[\"https:\/\/x.com\/VE6EY\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"NodeMCU I2C LCD Display Saves Pins - Making It Up","description":"Here's how to hook up the NodeMCU I2C LCD Display, and modify the library to run I2C on any of your GPIO pins D1 through D8.","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:\/\/play.fallows.ca\/wp\/projects\/electronics-projects\/nodemcu-i2c-lcd-display-saves-pins\/","og_locale":"en_US","og_type":"article","og_title":"NodeMCU I2C LCD Display Saves Pins - Making It Up","og_description":"Here's how to hook up the NodeMCU I2C LCD Display, and modify the library to run I2C on any of your GPIO pins D1 through D8.","og_url":"https:\/\/play.fallows.ca\/wp\/projects\/electronics-projects\/nodemcu-i2c-lcd-display-saves-pins\/","og_site_name":"Making It Up","article_publisher":"https:\/\/www.facebook.com\/john.fallows.5","article_published_time":"2016-11-28T13:26:38+00:00","article_modified_time":"2017-02-10T03:44:48+00:00","og_image":[{"url":"http:\/\/play.fallows.ca\/wp\/wp-content\/uploads\/sites\/4\/2016\/11\/NodeMCU-I2C-LCD.jpg","type":"","width":"","height":""}],"author":"John VE6EY","twitter_card":"summary_large_image","twitter_creator":"@VE6EY","twitter_site":"@VE6EY","twitter_misc":{"Written by":"John VE6EY","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/play.fallows.ca\/wp\/projects\/electronics-projects\/nodemcu-i2c-lcd-display-saves-pins\/","url":"https:\/\/play.fallows.ca\/wp\/projects\/electronics-projects\/nodemcu-i2c-lcd-display-saves-pins\/","name":"NodeMCU I2C LCD Display Saves Pins - Making It Up","isPartOf":{"@id":"https:\/\/play.fallows.ca\/wp\/#website"},"primaryImageOfPage":{"@id":"https:\/\/play.fallows.ca\/wp\/projects\/electronics-projects\/nodemcu-i2c-lcd-display-saves-pins\/#primaryimage"},"image":{"@id":"https:\/\/play.fallows.ca\/wp\/projects\/electronics-projects\/nodemcu-i2c-lcd-display-saves-pins\/#primaryimage"},"thumbnailUrl":"http:\/\/play.fallows.ca\/wp\/wp-content\/uploads\/sites\/4\/2016\/11\/NodeMCU-I2C-LCD.jpg","datePublished":"2016-11-28T13:26:38+00:00","dateModified":"2017-02-10T03:44:48+00:00","author":{"@id":"https:\/\/play.fallows.ca\/wp\/#\/schema\/person\/9750e0ab227030255d9806757525f945"},"description":"Here's how to hook up the NodeMCU I2C LCD Display, and modify the library to run I2C on any of your GPIO pins D1 through D8.","breadcrumb":{"@id":"https:\/\/play.fallows.ca\/wp\/projects\/electronics-projects\/nodemcu-i2c-lcd-display-saves-pins\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/play.fallows.ca\/wp\/projects\/electronics-projects\/nodemcu-i2c-lcd-display-saves-pins\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/play.fallows.ca\/wp\/projects\/electronics-projects\/nodemcu-i2c-lcd-display-saves-pins\/#primaryimage","url":"https:\/\/i0.wp.com\/play.fallows.ca\/wp\/wp-content\/uploads\/sites\/4\/2016\/11\/NodeMCU-I2C-LCD.jpg?fit=618%2C324&ssl=1","contentUrl":"https:\/\/i0.wp.com\/play.fallows.ca\/wp\/wp-content\/uploads\/sites\/4\/2016\/11\/NodeMCU-I2C-LCD.jpg?fit=618%2C324&ssl=1","width":618,"height":324,"caption":"nodemcu i2c lcd"},{"@type":"BreadcrumbList","@id":"https:\/\/play.fallows.ca\/wp\/projects\/electronics-projects\/nodemcu-i2c-lcd-display-saves-pins\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/play.fallows.ca\/wp\/"},{"@type":"ListItem","position":2,"name":"Projects","item":"https:\/\/play.fallows.ca\/wp\/category\/projects\/"},{"@type":"ListItem","position":3,"name":"Electronics Projects","item":"https:\/\/play.fallows.ca\/wp\/category\/projects\/electronics-projects\/"},{"@type":"ListItem","position":4,"name":"NodeMCU I2C LCD Display Saves Pins"}]},{"@type":"WebSite","@id":"https:\/\/play.fallows.ca\/wp\/#website","url":"https:\/\/play.fallows.ca\/wp\/","name":"Making It Up","description":"Enjoying Radio and Maker Hobbies","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/play.fallows.ca\/wp\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/play.fallows.ca\/wp\/#\/schema\/person\/9750e0ab227030255d9806757525f945","name":"John VE6EY","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/play.fallows.ca\/wp\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e4048edfe09efff51033c48b4fb951e8ac0a4dc84a25c96b25e5ae9f5b7069a5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e4048edfe09efff51033c48b4fb951e8ac0a4dc84a25c96b25e5ae9f5b7069a5?s=96&d=mm&r=g","caption":"John VE6EY"},"sameAs":["https:\/\/x.com\/VE6EY"]}]}},"share_on_mastodon":{"url":"","error":""},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6wNv5-pX","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/play.fallows.ca\/wp\/wp-json\/wp\/v2\/posts\/1609","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/play.fallows.ca\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/play.fallows.ca\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/play.fallows.ca\/wp\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/play.fallows.ca\/wp\/wp-json\/wp\/v2\/comments?post=1609"}],"version-history":[{"count":3,"href":"https:\/\/play.fallows.ca\/wp\/wp-json\/wp\/v2\/posts\/1609\/revisions"}],"predecessor-version":[{"id":1621,"href":"https:\/\/play.fallows.ca\/wp\/wp-json\/wp\/v2\/posts\/1609\/revisions\/1621"}],"wp:attachment":[{"href":"https:\/\/play.fallows.ca\/wp\/wp-json\/wp\/v2\/media?parent=1609"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/play.fallows.ca\/wp\/wp-json\/wp\/v2\/categories?post=1609"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/play.fallows.ca\/wp\/wp-json\/wp\/v2\/tags?post=1609"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/play.fallows.ca\/wp\/wp-json\/wp\/v2\/series?post=1609"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}