{
    "ok": true,
    "data": {
        "title": "Z-0235",
        "rev_id": 12965,
        "updated_at": "2023-04-18T06:50:43+00:00",
        "chunk_count": 17,
        "chunks": [
            {
                "title": "Z-0235",
                "rev_id": 12965,
                "heading_path": "",
                "chunk_index": 0,
                "content": "# Z-0235",
                "char_count": 8,
                "token_estimate": 2
            },
            {
                "title": "Z-0235",
                "rev_id": 12965,
                "heading_path": "2004 Serial LCD Module Display",
                "chunk_index": 1,
                "content": "<figure>\n<img src=\"LCD2004_02.jpg\" title=\"LCD2004_02.jpg\" width=\"300\" alt=\"LCD2004_02.jpg\" \/>\n<figcaption aria-hidden=\"true\">LCD2004_02.jpg<\/figcaption>\n<\/figure>\n\n-   Purchase URL \\[ <https:\/\/52pi.com\/products\/52pi-2004-serial-lcd-module-display> \\]",
                "char_count": 250,
                "token_estimate": 63
            },
            {
                "title": "Z-0235",
                "rev_id": 12965,
                "heading_path": "Description",
                "chunk_index": 2,
                "content": "The LCD has always been a device that acts as a window in human-computer interaction.\nFor example, the prompt window on some instrument devices, the temperature and humidity prompt box,\nthe device running status monitor, and the prompt screen of the counting device all have LCD figures.\nThe common LCD1602, LCD2004, and LCD12864 are fabricated using liquid crystal materials and communicated using the I2C bus.\nIt is a high-performance serial bus with bus rules and high-speed or low-speed device synchronization required for multi-master systems.\nThe I2C bus has only two bidirectional signal lines, a serial data line (SDA) and a serial clock line (SCL).\nCompatible with all devices with I2C interfaces, such as Arduino, raspberry pi, beagle bone black, tinker board, stm32, esp32 and more.\n==Features==\n\n-   20 Characters \\* 4 Lines, Character LCD module\n-   5V for Logic Circuit\n-   Low power consumption\n-   Support I2C protocol\n-   Default Register Address: New version: 0x3F, old version: 0x27\n-   Easy to use\n-   Compatible with Raspberry Pi, banana Pi, Tinker Board, STM32, ESP32 etc.\n-   Type: Chip On Board\n-   Number of Data line: 8-bit parallel\n-   Backlight Color: Yellow\n\n<!-- -->",
                "char_count": 1196,
                "token_estimate": 299
            },
            {
                "title": "Z-0235",
                "rev_id": 12965,
                "heading_path": "Description",
                "chunk_index": 3,
                "content": "After May. 27th 2022, the LCD2004 display screen and LCD1602 display screen of our products have been upgraded, and the register address of the new version is updated to 0x3F. The register address of the old version is 0x27, identification method: The new version contains \"MH\" in the silk screen of the rear adapter board and The distance between the potentiometer and the pad below is larger, and the old version is the opposite.\n\n<img src=\"Compations.jpeg\" title=\"Compations.jpeg\" width=\"800\" alt=\"Compations.jpeg\" \/>",
                "char_count": 520,
                "token_estimate": 130
            },
            {
                "title": "Z-0235",
                "rev_id": 12965,
                "heading_path": "Gallery",
                "chunk_index": 4,
                "content": "|                                                                                            |                                                                                      |                                                                                      |\n|--------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|\n| <figure>\n <img src=\"LCD2004_01-2.jpg\" title=\"LCD2004_01-2.jpg\" width=\"300\" alt=\"LCD2004_01-2.jpg\" \/>\n <figcaption aria-hidden=\"true\">LCD2004_01-2.jpg<\/figcaption>\n <\/figure>                                                                                   | <figure>\n                                                                                              <img src=\"LCD2004_06.jpg\" title=\"LCD2004_06.jpg\" width=\"300\" alt=\"LCD2004_06.jpg\" \/>\n                                                                                              <figcaption aria-hidden=\"true\">LCD2004_06.jpg<\/figcaption>",
                "char_count": 1138,
                "token_estimate": 285
            },
            {
                "title": "Z-0235",
                "rev_id": 12965,
                "heading_path": "Gallery",
                "chunk_index": 5,
                "content": "<\/figure>                                                                             | <figure>\n                                                                                                                                                                                     <img src=\"LCD2004_05.jpg\" title=\"LCD2004_05.jpg\" width=\"300\" alt=\"LCD2004_05.jpg\" \/>\n                                                                                                                                                                                     <figcaption aria-hidden=\"true\">LCD2004_05.jpg<\/figcaption>\n                                                                                                                                                                                     <\/figure>                                                                             |",
                "char_count": 871,
                "token_estimate": 218
            },
            {
                "title": "Z-0235",
                "rev_id": 12965,
                "heading_path": "Gallery",
                "chunk_index": 6,
                "content": "|                                                                                            |                                                                                                  |                                                                                                  |\n|--------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------|\n| <figure>\n <img src=\"LCD2004_07-2.jpg\" title=\"LCD2004_07-2.jpg\" width=\"300\" alt=\"LCD2004_07-2.jpg\" \/>\n <figcaption aria-hidden=\"true\">LCD2004_07-2.jpg<\/figcaption>\n <\/figure>                                                                                   | <figure>\n                                                                                              <img src=\"20190410112907.jpg\" title=\"20190410112907.jpg\" width=\"300\" alt=\"20190410112907.jpg\" \/>\n                                                                                              <figcaption aria-hidden=\"true\">20190410112907.",
                "char_count": 1186,
                "token_estimate": 297
            },
            {
                "title": "Z-0235",
                "rev_id": 12965,
                "heading_path": "Gallery",
                "chunk_index": 7,
                "content": "jpg<\/figcaption>\n                                                                                              <\/figure>                                                                                         | <figure>\n                                                                                                                                                                                                 <img src=\"20190410112912.jpg\" title=\"20190410112912.jpg\" width=\"300\" alt=\"20190410112912.jpg\" \/>\n                                                                                                                                                                                                 <figcaption aria-hidden=\"true\">20190410112912.jpg<\/figcaption>\n                                                                                                                                                                                                 <\/figure>                                                                                         |",
                "char_count": 1058,
                "token_estimate": 265
            },
            {
                "title": "Z-0235",
                "rev_id": 12965,
                "heading_path": "Package Include",
                "chunk_index": 8,
                "content": "-   1 x LCD2004\n-   4 x Jumpwire\n\n<img src=\"LCD2004_05.jpg\" title=\"LCD2004_05.jpg\" width=\"300\" alt=\"LCD2004_05.jpg\" \/>",
                "char_count": 118,
                "token_estimate": 30
            },
            {
                "title": "Z-0235",
                "rev_id": 12965,
                "heading_path": "How to assemble it to Raspberry Pi",
                "chunk_index": 9,
                "content": "-   LCD2004 communicates with Raspberry Pi via I2C protocol.\n-   Connect LCD2004 module to Raspberry Pi as following picture:\n\n------------------------------------------------------------------------\n\n| I2C LCD2004 | Raspberry Pi |\n|-------------|--------------|\n| GND         | GND          |\n| VCC         | 5V           |\n| SDA         | SDA          |\n| SCL         | SCL          |\n|             |              |\n\n|                                                |                                                 |\n|------------------------------------------------|-------------------------------------------------|\n| ![ left \\|400px ](LCDGPIO.png \" left |400px \") | ![ right\\| 400px](Rpidemo2.png \" right| 400px\") |",
                "char_count": 721,
                "token_estimate": 181
            },
            {
                "title": "Z-0235",
                "rev_id": 12965,
                "heading_path": "How to test it",
                "chunk_index": 10,
                "content": "-   Reference program writing:\n\n(The following program can recognize the screen used for 27 address and 3F address at the same time) Demo code in programming language C:\n\n    #include <Wire.h>\n    #include <LiquidCrystal_I2C.h>\n\n    void setup()\n    {\n        byte error;\n        Wire.begin();\n        Wire.beginTransmission(0x27);\n        error = Wire.endTransmission();\n        if(error == 0){                      \/\/ If your device is 0x27\n          LiquidCrystal_I2C lcd(0x27,20,4);\n          lcd.init();\n          lcd.backlight();\n          lcd.setCursor(0,0);\n          lcd.print(\"Device Addr = 0x27\");\n        }else{                               \/\/ If your device is 0x3F\n          LiquidCrystal_I2C lcd(0x3F,20,4);\n          lcd.init();\n          lcd.backlight();\n          lcd.setCursor(0,0);\n          lcd.print(\"Device Addr = 0x3F\");\n        }\n    }\n\n    void loop(){}\n\n-   Compile it and run:\n\n<!-- -->\n\n    gcc get_register_address.c\n    .\/a.out",
                "char_count": 959,
                "token_estimate": 240
            },
            {
                "title": "Z-0235",
                "rev_id": 12965,
                "heading_path": "Demo code",
                "chunk_index": 11,
                "content": "-   Raspberry Pi\n\n1\\. Connect LCD2004 to Raspberry Pi's I2C Pins via jumpwire\n2. Open a terminal and typing following command:\n`sudo apt-get update`\n`sudo apt-get upgrade`\n3. Enable I2C function.\n`sudo raspi-config`\nNavigate to \"Interface Option\" and select \"i2c\" and enable it.\n4.Download and install python-liquidcrystal_i2c library.\nDownload python-liquidcrystal_i2c\/archive\/master.zip and install it to Raspberry Pi as following command:\n`python -m easy_install --user `[`https:\/\/github.com\/pl31\/python-liquidcrystal_i2c\/archive\/master.zip`](https:\/\/github.com\/pl31\/python-liquidcrystal_i2c\/archive\/master.zip)\n\\* Second way to install library.\nOr you can download it from here: \\[ <http:\/\/wiki.52pi.com\/index.php\/File:Python-liquidcrystal_i2c-master.zip> \\]\nUsing python -m easy_install --user Python-liquidcrystal_i2c-master.zip to install it.\n5. Write demo code and test it.\nCopy and paste following code to a file named lcd2004.py:",
                "char_count": 939,
                "token_estimate": 235
            },
            {
                "title": "Z-0235",
                "rev_id": 12965,
                "heading_path": "Demo code",
                "chunk_index": 12,
                "content": "#!\/usr\/bin\/env python\n    \"\"\"first please add python library via this command: python -m easy_install --user https:\/\/github.com\/pl31\/python-liquidcrystal_i2c\/archive\/master.zip \"\"\"\n    import socket\n    import os.path\n    import sys\n    import struct\n    import fcntl\n    import os\n    import time\n    import liquidcrystal_i2c\n    efg = \"0\"\n    wfg = \"0\"\n    lcd = liquidcrystal_i2c.LiquidCrystal_I2C(0x27, 1, numlines=4)\n    PATH1=\"\/sys\/class\/net\/eth0\/carrier\"\n    PATH2 = \"\/sys\/class\/net\/wlan0\/carrier\"\n    def getserial():\n        snm = \"0000000000000000\"\n        try:\n            f = open('\/proc\/cpuinfo','r')\n            for line in f:\n                if line[0:6]=='Serial':\n                    snm = line[10:26]\n            f.close()\n        except:\n            snm = \"ERROR\"\n        return snm",
                "char_count": 801,
                "token_estimate": 201
            },
            {
                "title": "Z-0235",
                "rev_id": 12965,
                "heading_path": "Demo code",
                "chunk_index": 13,
                "content": "def getip(ifname):\n        tt=0\n        while tt<100:\n            try:\n                s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)\n                return socket.inet_ntoa(fcntl.ioctl(s.fileno(),0x8915,struct.pack('256s',ifname[:15]))[20:24])\n            except:\n                tt+=1\n                time.sleep(1)\n                if(tt>99):\n                    return('ERROR')\n    time.sleep(15)\n    pstr= 'SN:'+getserial()\n    lcd.printline(0,pstr)\n    pstr = 'HN:'+socket.gethostname()\n    lcd.printline(1,pstr)\n    if os.path.isfile(PATH1) and os.access(PATH1, os.R_OK):\n        efg = open(PATH1).read()\n        pstr = 'EM:'+open('\/sys\/class\/net\/eth0\/address').read()\n        pstr = pstr.strip('\\n')\n        lcd.printline(2,pstr)\n        if efg[0]==\"1\":\n            pstr='EIP:'+str(getip('eth0'))\n            lcd.printline(3,pstr)\n        elif os.path.isfile(PATH2) and os.access(PATH2, os.R_OK):\n            wfg = open(PATH2).read()\n            pstr=\"WM:\"+open('\/sys\/class\/net\/wlan0\/address').read()\n            pstr = pstr.strip('\\n')\n            lcd.printline(2,pstr)\n            if wfg[0]==\"1\":\n                pstr=\"WIP:\"+str(getip('wlan0'))\n                lcd.printline(3,pstr)",
                "char_count": 1196,
                "token_estimate": 299
            },
            {
                "title": "Z-0235",
                "rev_id": 12965,
                "heading_path": "Demo code",
                "chunk_index": 14,
                "content": "6\\. Test it\nsave it and run it.\n`python lcd2004.py`\nYou will see your Raspberry Pi's Serial Number, Hostname, WiFi Mac address and WiFi IP address.\n<img src=\"Lcd2004_demo1.jpg\" title=\"Lcd2004_demo1.jpg\" width=\"500\" alt=\"Lcd2004_demo1.jpg\" \/>\n\\* Arduino 1. Connect LCD2004 to Arduino Uno: ![ left\\|500px ](Arduinowire.jpg \" left|500px \")\n2. Download library from boardmanager and install following library:\n<img src=\"Arduinolib.png\" title=\"Arduinolib.png\" width=\"500\" alt=\"Arduinolib.png\" \/>\n3. Build Sketch file and upload to your Arduino Uno.\nOpen your Arduino IDE and then copy paste following code and select your port and the type of your board, press upload icon to upload sketch.\n\n#include <Wire.h>\n    #include <LiquidCrystal_I2C.h>\n\nLiquidCrystal_I2C lcd(0x27,20,4);  \/\/ set the LCD address to 0x27 for a 16 chars and 2 line display",
                "char_count": 840,
                "token_estimate": 210
            },
            {
                "title": "Z-0235",
                "rev_id": 12965,
                "heading_path": "Demo code",
                "chunk_index": 15,
                "content": "void setup()\n    {\n      lcd.init();                      \/\/ initialize the lcd\n      lcd.init();\n      \/\/ Print a message to the LCD.\n      lcd.backlight();\n      lcd.setCursor(0,0);\n      lcd.print(\"--------------------\");\n      lcd.setCursor(6,1);\n      lcd.print(\"GEEEKPI\");\n       lcd.setCursor(1,2);\n      lcd.print(\"Arduino IIC Screen\");\n       lcd.setCursor(0,3);\n      lcd.print(\"--------------------\");\n    }\n\nvoid loop()\n    {\n    \/\/ Just loop, do nothing.\n    }\n\n4\\. Connect Arduino to PC via USB cable, you will see: ![ left \\|500px ](Lcd2004demo2.jpg \" left |500px \")",
                "char_count": 581,
                "token_estimate": 146
            },
            {
                "title": "Z-0235",
                "rev_id": 12965,
                "heading_path": "Keywords",
                "chunk_index": 16,
                "content": "LCD2004, liquid crystal Display, Raspberry Pi display, i2c protocol display, LCD",
                "char_count": 80,
                "token_estimate": 20
            }
        ]
    }
}