{"id":24372,"date":"2021-12-10T09:28:38","date_gmt":"2021-12-10T00:28:38","guid":{"rendered":"https:\/\/www.souichi.club\/?p=24372"},"modified":"2022-03-19T17:17:27","modified_gmt":"2022-03-19T08:17:27","slug":"i2c-lcd","status":"publish","type":"post","link":"https:\/\/www.souichi.club\/en\/m5stack\/i2c-lcd\/","title":{"rendered":"Tried I2C LCD (liquid crystal display) with ESP32-WROOM-32"},"content":{"rendered":"<ul class=\"bogo-language-switcher list-view\"><li class=\"en-US en current first\"><span class=\"bogoflags bogoflags-us\"><\/span> <span class=\"bogo-language-name\"><a rel=\"alternate\" hreflang=\"en-US\" href=\"https:\/\/www.souichi.club\/en\/wp-json\/wp\/v2\/posts\/24372\/\" title=\"English\" class=\"current\" aria-current=\"page\">English<\/a><\/span><\/li>\n<li class=\"ja last\"><span class=\"bogoflags bogoflags-jp\"><\/span> <span class=\"bogo-language-name\"><a rel=\"alternate\" hreflang=\"ja\" href=\"https:\/\/www.souichi.club\/wp-json\/wp\/v2\/posts\/24372\/\" title=\"Japanese\">\u65e5\u672c\u8a9e<\/a><\/span><\/li>\n<\/ul>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_79_2 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69dbf7da47661\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #454e5c;color:#454e5c\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #454e5c;color:#454e5c\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69dbf7da47661\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/i2c-lcd\/#I2C_LCD\" >I2C LCD<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/i2c-lcd\/#Features_of_LCD\" >Features of LCD<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/i2c-lcd\/#Environment\" >Environment<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/i2c-lcd\/#Wiring_Diagram\" >Wiring Diagram<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/i2c-lcd\/#Advance_preparation\" >Advance preparation<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/i2c-lcd\/#Download_the_library_for_I2C_connection\" >Download the library for I2C connection<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/i2c-lcd\/#Include_the_library\" >Include the library<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/i2c-lcd\/#Sample_program\" >Sample program<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/i2c-lcd\/#I2cLcd-enino\" >I2cLcd-en.ino<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/i2c-lcd\/#Additional_explanation\" >Additional explanation<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/i2c-lcd\/#I2C_address\" >I2C address<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/i2c-lcd\/#Display_the_number_of_seconds\" >Display the number of seconds<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/i2c-lcd\/#Auto-scroll\" >Auto-scroll<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/i2c-lcd\/#Shifting_one_character\" >Shifting one character<\/a><\/li><\/ul><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/i2c-lcd\/#Other_Features\" >Other Features<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/i2c-lcd\/#Contrast\" >Contrast<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/i2c-lcd\/#Backlight_adjustment\" >Backlight adjustment<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"I2C_LCD\"><\/span>I2C LCD<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>An article on running a sample program by connecting an I2C 1602 16&#215;2 character LCD module display to an ESP32 (ESP32-WROOM-32) development module.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><a class=\"r_image\" href=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-13.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-13.jpg?resize=480%2C321&#038;ssl=1\" alt=\"ESP32-WROOM-32\u3068I2C LCD\" class=\"wp-image-24298\" width=\"480\" height=\"321\" srcset=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-13.jpg?w=1920&amp;ssl=1 1920w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-13.jpg?resize=768%2C514&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-13.jpg?resize=1536%2C1028&amp;ssl=1 1536w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/a><\/figure>\n\n\n\n<p>ESP32-WROOM-32 is a chip that adds Wi-Fi and Bluetooth to ESP32.<\/p>\n\n\n\n<p>In this case, I used Aideepen brand products, but be aware that some modules have different pin assignments.<\/p>\n\n\n\n<p>The pin layout of the product used in this project is the same as that of ESP32 DEVKIT V1, and a picture of it can be <a href=\"https:\/\/github.com\/Nicholas3388\/LuaNode\" target=\"_blank\" rel=\"noreferrer noopener\">found here<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><a class=\"r_image\" href=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-01.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-01.jpg?resize=480%2C535&#038;ssl=1\" alt=\"ESP32-WROOM-32\" class=\"wp-image-24374\" width=\"480\" height=\"535\" srcset=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-01.jpg?w=1920&amp;ssl=1 1920w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-01.jpg?resize=768%2C855&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-01.jpg?resize=1379%2C1536&amp;ssl=1 1379w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-01.jpg?resize=1839%2C2048&amp;ssl=1 1839w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Features_of_LCD\"><\/span>Features of LCD<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>There are a number of inexpensive LCD (Liquid Crystal Display) products available for 16 characters x 2 lines.<\/p>\n\n\n\n<p>I chose a display with an I2C (Inter-Integrated Circuit) terminal for easy connection to the ESP32-WROOM-32.<\/p>\n\n\n\n<p>The serial communication is not fast enough to display information such as temperature, humidity, and pressure.<\/p>\n\n\n\n<p>LCD specifications are as follows<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Display size: 64.5mm x 16mm<\/li><li>5V DC (I was able to display at 3.3V, but the display is quite thin, see below for details)<\/li><li>16 characters x 2 lines<\/li><li>Connection: I2C<\/li><\/ul>\n\n\n\n<p>I bought a product that has a module for I2C connection on the display.<\/p>\n\n\n\n<p>It is also possible to purchase the display and I2C connection module separately.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><a class=\"r_image\" href=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-03.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-03.jpg?resize=480%2C283&#038;ssl=1\" alt=\"I2C LCD\" class=\"wp-image-24266\" width=\"480\" height=\"283\" srcset=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-03.jpg?w=1920&amp;ssl=1 1920w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-03.jpg?resize=768%2C452&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-03.jpg?resize=1536%2C905&amp;ssl=1 1536w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Environment\"><\/span>Environment<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The sample program was developed and compiled in the Arduino IDE on Windows, and written to the ESP32-WROOM-32 via USB.<\/p>\n\n\n\n<p>The environment is as follows.<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-regular\">\n<table class=\"r_table01\">\n<tbody>\n<tr>\n<td class=\"r_td30\">\n<p>OS<\/p>\n<\/td>\n<td>\n<p>Windows 10 Home\uff0864 Bit\uff09<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Arduino IDE<\/p>\n<\/td>\n<td>\n<p>1.8.13<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Wiring_Diagram\"><\/span>Wiring Diagram<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Wiring diagram between ESP32-WROOM-32 module and I2C LCD.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><a class=\"r_image\" href=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-02.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-02.png?resize=768%2C532&#038;ssl=1\" alt=\"ESP32-WROOM-32 \u3068 I2C LCD \u3068\u306e\u914d\u7dda\u56f3\" class=\"wp-image-24262\" width=\"768\" height=\"532\" srcset=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-02.png?resize=1024%2C709&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-02.png?resize=300%2C208&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-02.png?resize=768%2C532&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-02.png?resize=1536%2C1063&amp;ssl=1 1536w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-02.png?w=1560&amp;ssl=1 1560w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>I measured VIN with a tester and it was 4.736V<\/li><li>D21 of ESP32-WROOM-32 is connected to SDA and D22 to SCL<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Advance_preparation\"><\/span>Advance preparation<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Download_the_library_for_I2C_connection\"><\/span>Download the library for I2C connection<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Install the library for I2C LCD in Arduino IDE.<\/p>\n\n\n\n<p>When I tried to install the LiquidCrystal I2C library from <a href=\"https:\/\/www.arduino.cc\/reference\/en\/libraries\/liquidcrystal-i2c\/\" target=\"_blank\" rel=\"noreferrer noopener\">this page<\/a>, the last version was 1.1.2, but there was a 1.1.3 version by the same author, so I <a href=\"https:\/\/github.com\/johnrickman\/LiquidCrystal_I2C\/archive\/1.1.3.zip\" target=\"_blank\" rel=\"noreferrer noopener\">downloaded it<\/a>.<br>(File name: LiquidCrystal_I2C-1.1.3.zip)<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Include_the_library\"><\/span>Include the library<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Start the Arduino IDE and select Sketch &gt; Include Library &gt; Add .ZIP Library.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><a class=\"r_image\" href=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-02.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-02.png?resize=670%2C441&#038;ssl=1\" alt=\"Add ZIP Library\" class=\"wp-image-24376\" width=\"670\" height=\"441\" srcset=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-02.png?w=1340&amp;ssl=1 1340w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-02.png?resize=768%2C506&amp;ssl=1 768w\" sizes=\"auto, (max-width: 670px) 100vw, 670px\" \/><\/a><\/figure>\n\n\n\n<p>Select the ZIP file that you have just downloaded.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><a class=\"r_image\" href=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-07.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-07.png?resize=438%2C318&#038;ssl=1\" alt=\"select the ZIP file\" class=\"wp-image-24388\" width=\"438\" height=\"318\" srcset=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-07.png?w=875&amp;ssl=1 875w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-07.png?resize=768%2C558&amp;ssl=1 768w\" sizes=\"auto, (max-width: 438px) 100vw, 438px\" \/><\/a><\/figure>\n\n\n\n<p>The library is added and the installation is finished.<\/p>\n\n\n\n<p>By default, the library will be installed in a folder under C:\\Users\\Username\\Documents\\Arduino\\libraries\\.<\/p>\n\n\n\n<p>To check the location, go to File &gt; Preferences &gt; Sketchbook Location.<\/p>\n\n\n\n<p>If you want to uninstall the library, just delete this folder.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><a class=\"r_image\" href=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-06.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-06.png?resize=857%2C488&#038;ssl=1\" alt=\"folder\" class=\"wp-image-24385\" width=\"857\" height=\"488\" srcset=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-06.png?w=1714&amp;ssl=1 1714w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-06.png?resize=768%2C437&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-06.png?resize=1536%2C874&amp;ssl=1 1536w\" sizes=\"auto, (max-width: 857px) 100vw, 857px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Sample_program\"><\/span>Sample program<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The sample program is as follows.<\/p>\n\n\n\n<p>It is just a sketch that counts up &#8220;Start&#8221; on the first line and a number on the second line.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"I2cLcd-enino\"><\/span>I2cLcd-en.ino<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n<pre class=\"line-numbers\"><code class=\"lang-cpp\">\/*\n *   I2C 1602 16x2 LCD test Sketch\n * \n *\/\n\n#include &lt;LiquidCrystal_I2C.h&gt;\n\nLiquidCrystal_I2C lcd(0x27,16,2);  \/\/ I2C addr\u300116x2 \n\nvoid setup() {\n    Serial.begin(115200);\n    lcd.init();\n    lcd.backlight();\n    \/*\n    lcd.autoscroll();\n    *\/\n    lcd.clear();\n    lcd.setCursor(0, 0);\n    lcd.print(\"Start\");\n    lcd.setCursor(0, 1);\n    lcd.print(\"Count:\");\n}\n\nvoid loop() {\n    lcd.setCursor(6, 1);\n    int times=millis() \/ 1000; \/\/ Number of milliseconds since program start\n    lcd.print(times);\n    \/*\n    lcd.scrollDisplayRight();\n    *\/\n    Serial1.println(times);\n    delay(1000);\n}<\/code><\/pre>\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Additional_explanation\"><\/span>Additional explanation<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>For the commands available in LiquidCrystal Library, <a href=\"https:\/\/www.arduino.cc\/en\/Reference\/LiquidCrystal\" target=\"_blank\" rel=\"noreferrer noopener\">please refer to this page<\/a>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"I2C_address\"><\/span>I2C address<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>First, the I2C address and the number of characters and lines of the character are specified.<\/p>\n\n\n<pre class=\"line-numbers\"><code class=\"lang-cpp\">LiquidCrystal_I2C lcd(0x27,16,2);  \/\/ I2C addr, 16x2 character<\/code><\/pre>\n\n\n<p>The default I2C address is 0x27 for the product I purchased, but other addresses may be assigned depending on the product.<\/p>\n\n\n\n<p>The address is scanned with the address assigned by <a href=\"https:\/\/playground.arduino.cc\/Main\/I2cScanner\/\" target=\"_blank\" rel=\"noreferrer noopener\">I2CScanner here<\/a>.<\/p>\n\n\n\n<p>I changed the first Serial.begin(9600); to Serial.begin(115200); and used it.<\/p>\n\n\n\n<p>The I2C address can be changed with the solder jumper on the back.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><a class=\"r_image\" href=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-03.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-03.jpg?resize=480%2C259&#038;ssl=1\" alt=\"Solder jumper\" class=\"wp-image-24379\" width=\"480\" height=\"259\" srcset=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-03.jpg?w=1920&amp;ssl=1 1920w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-03.jpg?resize=768%2C414&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-03.jpg?resize=1536%2C828&amp;ssl=1 1536w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/a><\/figure>\n\n\n\n<p>In the above picture, A0, A1, and A2 are open (unconnected at the top and bottom), so the value is 0x27. However, if this jumper is shorted with solder, the address will change.<\/p>\n\n\n\n<p>0: Short<\/p>\n\n\n\n<p>1: Open<\/p>\n\n\n<table class=\"r_table01\">\n<tbody>\n<tr>\n<td>A2<\/td>\n<td>A1<\/td>\n<td>A0<\/td>\n<td>I2C Address<\/td>\n<\/tr>\n<tr>\n<td>0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0x20<\/td>\n<\/tr>\n<tr>\n<td>0<\/td>\n<td>0<\/td>\n<td>1<\/td>\n<td>0x21<\/td>\n<\/tr>\n<tr>\n<td>0<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>0x22<\/td>\n<\/tr>\n<tr>\n<td>0<\/td>\n<td>1<\/td>\n<td>1<\/td>\n<td>0x23<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>0x24<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>0<\/td>\n<td>1<\/td>\n<td>0x25<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>1<\/td>\n<td>0<\/td>\n<td>0x26<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>1<\/td>\n<td>1<\/td>\n<td>0x27<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Display_the_number_of_seconds\"><\/span>Display the number of seconds<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>millis() is a function that returns the time in milliseconds from when the Arduino board started executing the program to the present.<\/p>\n\n\n\n<p>It divides the time by 1000, converts it to seconds, and displays it on the display with lcd.print.<\/p>\n\n\n<pre class=\"line-numbers\"><code class=\"lang-cpp\">    int times=millis() \/ 1000;\n    lcd.print(times);<\/code><\/pre>\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Auto-scroll\"><\/span>Auto-scroll<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>Although it is commented out in the sketch, it can be automatically scrolled from right to left.<\/p>\n\n\n<pre class=\"line-numbers\"><code class=\"lang-cpp\">    lcd.autoscroll();<\/code><\/pre>\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Shifting_one_character\"><\/span>Shifting one character<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>If you uncomment the text, it will scroll by shifting one character to the right.<\/p>\n\n\n<pre class=\"line-numbers\"><code class=\"lang-cpp\">    lcd.scrollDisplayRight();<\/code><\/pre>\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Other_Features\"><\/span>Other Features<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Contrast\"><\/span>Contrast<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The contrast (lightness and darkness) of the display can be adjusted with the semi-fixed resistors on the back.<\/p>\n\n\n\n<p>When I first ran the sample program, nothing was displayed and I suspected a wiring or programming error, but after turning the variable resistor clockwise with a Phillips screwdriver, the display came back on.<\/p>\n\n\n\n<p>However, when I turned the variable resistor clockwise with a Phillips screwdriver, the display came on. In the factory default state, even when connected to 5V, the characters were not visible unless the semi-fixed resistor was turned slightly clockwise.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><a class=\"r_image\" href=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-04.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-04.jpg?resize=480%2C259&#038;ssl=1\" alt=\"variable resistor\" class=\"wp-image-24380\" width=\"480\" height=\"259\" srcset=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-04.jpg?w=1920&amp;ssl=1 1920w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-04.jpg?resize=768%2C414&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-04.jpg?resize=1536%2C828&amp;ssl=1 1536w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/a><\/figure>\n\n\n\n<p>When I connected VCC to 3.3V, I could barely see the variable resistors when I turned them clockwise to the maximum, so basically you should think you need a 5V power supply.<\/p>\n\n\n\n<p>You can see the difference between the photo and the naked eye, but the 3.3V connection is with the variable resistor turned clockwise as far as it will go.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><a class=\"r_image\" href=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-11.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-11.jpg?resize=480%2C131&#038;ssl=1\" alt=\"Comparison of 5V and 3V3\" class=\"wp-image-24287\" width=\"480\" height=\"131\" srcset=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-11.jpg?w=1920&amp;ssl=1 1920w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-11.jpg?resize=768%2C210&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-11.jpg?resize=1536%2C419&amp;ssl=1 1536w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Backlight_adjustment\"><\/span>Backlight adjustment<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>There is a jumper pin on the back for backlight adjustment.<\/p>\n\n\n\n<p>When it is removed, the backlight is turned off.<\/p>\n\n\n\n<p>The intensity of the backlight can be adjusted by inserting a variable resistor (not tested).<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><a class=\"r_image\" href=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-05.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-05.jpg?resize=480%2C259&#038;ssl=1\" alt=\"Jumper pin for backlight adjustment\" class=\"wp-image-24382\" width=\"480\" height=\"259\" srcset=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-05.jpg?w=1920&amp;ssl=1 1920w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-05.jpg?resize=768%2C414&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/i2c-lcd-en-05.jpg?resize=1536%2C828&amp;ssl=1 1536w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/a><\/figure>\n\n\n\n<p>This concludes this article.<\/p>\n\n\n<div class=\"postscript_balloon\">Finally.<\/div>\n\n\n<p>I hope this article will be useful to someone somewhere.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is an article about running a sample program with an ESP32 (ESP32-WROOM-32) connected to an I2C 1602 16&#215;2 character LCD module display.<\/p>\n","protected":false},"author":5,"featured_media":24357,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"en_US","_original_post":"https:\/\/www.souichi.club\/?p=24239","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[238],"tags":[],"class_list":["post-24372","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-m5stack","en-US"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/m5stickc-aws-iot-core-en-01.png?fit=1470%2C1080&ssl=1","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.souichi.club\/wp-json\/wp\/v2\/posts\/24372","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.souichi.club\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.souichi.club\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.souichi.club\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.souichi.club\/wp-json\/wp\/v2\/comments?post=24372"}],"version-history":[{"count":10,"href":"https:\/\/www.souichi.club\/wp-json\/wp\/v2\/posts\/24372\/revisions"}],"predecessor-version":[{"id":24391,"href":"https:\/\/www.souichi.club\/wp-json\/wp\/v2\/posts\/24372\/revisions\/24391"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.souichi.club\/wp-json\/wp\/v2\/media\/24357"}],"wp:attachment":[{"href":"https:\/\/www.souichi.club\/wp-json\/wp\/v2\/media?parent=24372"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.souichi.club\/wp-json\/wp\/v2\/categories?post=24372"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.souichi.club\/wp-json\/wp\/v2\/tags?post=24372"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}