{
    "ok": true,
    "data": {
        "title": "D-0006",
        "rev_id": 10821,
        "updated_at": "2021-08-27T10:50:37+00:00",
        "chunk_count": 17,
        "chunks": [
            {
                "title": "D-0006",
                "rev_id": 10821,
                "heading_path": "",
                "chunk_index": 0,
                "content": "# D-0006",
                "char_count": 8,
                "token_estimate": 2
            },
            {
                "title": "D-0006",
                "rev_id": 10821,
                "heading_path": "PCF8574T LCD Driver Board",
                "chunk_index": 1,
                "content": "[right \\|500px](File:D_0006_1.jpg \"wikilink\")",
                "char_count": 45,
                "token_estimate": 12
            },
            {
                "title": "D-0006",
                "rev_id": 10821,
                "heading_path": "Description",
                "chunk_index": 2,
                "content": "The PCF8574T IO Expansion Board is used as remote 8-bit I\/O expander for I2C-bus.\nUp to 8 PCF8574T IO Expansion Board can be connected to the I2C-bus, providing up to 64 I\/O ports.\nThe PCF8574T IO Expansion Board features allowing the use of multi module connected to the I2C bus at the same time by connecting the pinheader and connector.\nThere is a small potentiometer onboard, which can adjust the backlight of LCD1602 or LCD2004, and a jumper cap to control the switch of the LED light.",
                "char_count": 490,
                "token_estimate": 123
            },
            {
                "title": "D-0006",
                "rev_id": 10821,
                "heading_path": "Features",
                "chunk_index": 3,
                "content": "-   PCF8574T Chip\n-   I2C interface\n-   8-bit parallel port\n-   Potentiometer Backlight control\n-   LED jumper switch\n-   Default I2C address: 0x27",
                "char_count": 147,
                "token_estimate": 37
            },
            {
                "title": "D-0006",
                "rev_id": 10821,
                "heading_path": "Gallery",
                "chunk_index": 4,
                "content": "|                                                                                |                                                                                |                                                                                |\n|--------------------------------------------------------------------------------|--------------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| <figure>\n <img src=\"D_0006_1.jpg\" title=\"D_0006_1.jpg\" width=\"320\" alt=\"D_0006_1.jpg\" \/>\n <figcaption aria-hidden=\"true\">D_0006_1.jpg<\/figcaption>\n <\/figure>                                                                       | <figure>\n                                                                                  <img src=\"D_0006_2.jpg\" title=\"D_0006_2.jpg\" width=\"320\" alt=\"D_0006_2.jpg\" \/>\n                                                                                  <figcaption aria-hidden=\"true\">D_0006_2.jpg<\/figcaption>",
                "char_count": 1030,
                "token_estimate": 258
            },
            {
                "title": "D-0006",
                "rev_id": 10821,
                "heading_path": "Gallery",
                "chunk_index": 5,
                "content": "<\/figure>                                                                       | <figure>\n                                                                                                                                                                   <img src=\"D_0006_4.jpg\" title=\"D_0006_4.jpg\" width=\"320\" alt=\"D_0006_4.jpg\" \/>\n                                                                                                                                                                   <figcaption aria-hidden=\"true\">D_0006_4.jpg<\/figcaption>\n                                                                                                                                                                   <\/figure>                                                                       |",
                "char_count": 797,
                "token_estimate": 200
            },
            {
                "title": "D-0006",
                "rev_id": 10821,
                "heading_path": "Gallery > Dimenssion",
                "chunk_index": 6,
                "content": "<img src=\"D_0006_6.jpg\" title=\"D_0006_6.jpg\" width=\"500\" alt=\"D_0006_6.jpg\" \/>",
                "char_count": 78,
                "token_estimate": 20
            },
            {
                "title": "D-0006",
                "rev_id": 10821,
                "heading_path": "Package Includes",
                "chunk_index": 7,
                "content": "-   1 x PCF8574T LCD Driver Board",
                "char_count": 33,
                "token_estimate": 9
            },
            {
                "title": "D-0006",
                "rev_id": 10821,
                "heading_path": "Reference",
                "chunk_index": 8,
                "content": "-   PCF8574T Chip Datasheet: [File:PCF8574T Datasheet.pdf](File:PCF8574T_Datasheet.pdf \"wikilink\")\n-   WiringPi: \\[ <http:\/\/wiringpi.com\/extensions\/i2c-pcf8574\/> \\]\n-   telecnatron:\\[ <https:\/\/telecnatron.com\/articles\/Utility-To-Control-1602-LCD-On-Raspberry-Pi-Via-A-PCF8574-I2C-Backpack-Module\/index.html>\\]\n-   Circuitbasics:\\[ <https:\/\/www.circuitbasics.com\/raspberry-pi-i2c-lcd-set-up-and-programming\/> \\]",
                "char_count": 410,
                "token_estimate": 103
            },
            {
                "title": "D-0006",
                "rev_id": 10821,
                "heading_path": "Demo Code For Handle PCF8574T",
                "chunk_index": 9,
                "content": "-   Download and reinstall wiringPi liberary\n\n<!-- -->\n\n    sudo apt -y purge wiringpi\n    hash -r\n    cd \/tmp\n    wget https:\/\/project-downloads.drogon.net\/wiringpi-latest.deb\n    sudo dpkg -i wiringpi-latest.deb\n\n-   C++ language\n\n<!-- -->\n\n    #include <stdio.h>\n    #include <time.h>\n    #include <string>\n\n    #include <wiringPi.h>\n    #include <pcf8574.h>\n\n    using namespace std;\n    int main (int argc, char *argv[]){\n        printf(\"Raspberry Pi initializing...\\n\");\n\n            wiringPiSetup();\n        pcf8574Setup(100, 0x38);\n\n        for (int i = 0; i < 8; ++i){\n                pinMode(100 + i, OUTPUT);\n        }\n\n            int b=0;\n            while( 1==1 ){\n                    printf(\"LOOP %u\\n\", b);\n                    for (int i = 0; i < 8; ++i){\n                        digitalWrite(100 + i, i==b ? 0 : 1);\n                    }\n                    b++;\n            if( b >= 8 ) b=0;\n            delay(1000);\n\n        }\n\n        delay(1000);\n        digitalWrite(100 + 0, 0);\n\n        delay(1000);\n            digitalWrite(100 + 0, 1);\n\n        return 0;\n    }\n\n-   Compile and run it.\n\n<!-- -->\n\n    g++ pcf8574.cpp -o pcf8574 -lwiringPi -std=c++11\n    .\/pcf8574",
                "char_count": 1189,
                "token_estimate": 298
            },
            {
                "title": "D-0006",
                "rev_id": 10821,
                "heading_path": "Demo Code For Handle PCF8574T > Python Demo Code",
                "chunk_index": 10,
                "content": "-   Copy following code and save it as: I2C_LCD_driver.py\n\n<!-- -->\n\n# -*- coding: utf-8 -*-\n\n# Original code found at:\n\n# https:\/\/gist.github.com\/DenisFromHR\/cc863375a6e19dce359d\n\n\"\"\"\n    Compiled, mashed and generally mutilated 2014-2015 by Denis Pleic\n    Made available under GNU GENERAL PUBLIC LICENSE\n\n# Modified Python I2C library for Raspberry Pi\n\n# as found on http:\/\/www.recantha.co.uk\/blog\/?p=4849\n\n# Joined existing 'i2c_lib.py' and 'lcddriver.py' into a single library\n\n# added bits and pieces from various sources\n\n# By DenisFromHR (Denis Pleic)\n\n# 2015-02-10, ver 0.1\n\n\"\"\"\n\n# i2c bus (0 -- original Pi, 1 -- Rev 2 Pi)\n\n# I2CBUS = 0\n\nI2CBUS = 1\n\n# LCD Address\n\n#ADDRESS = 0x3f\n    ADDRESS = 0x27\n\nimport smbus\n    from time import sleep\n\nclass i2c_device:\n       def (self, addr, port=I2CBUS):\n          self.addr = addr\n          self.bus = smbus.SMBus(port)\n\n# Write a single command\n\ndef write_cmd(self, cmd):\n          self.bus.write_byte(self.addr, cmd)\n          sleep(0.0001)\n\n# Write a command and argument\n\ndef write_cmd_arg(self, cmd, data):\n          self.bus.write_byte_data(self.addr, cmd, data)\n          sleep(0.0001)\n\n# Write a block of data",
                "char_count": 1171,
                "token_estimate": 293
            },
            {
                "title": "D-0006",
                "rev_id": 10821,
                "heading_path": "Demo Code For Handle PCF8574T > Python Demo Code",
                "chunk_index": 11,
                "content": "def write_block_data(self, cmd, data):\n          self.bus.write_block_data(self.addr, cmd, data)\n          sleep(0.0001)\n\n# Read a single byte\n\ndef read(self):\n          return self.bus.read_byte(self.addr)\n\n# Read\n\ndef read_data(self, cmd):\n          return self.bus.read_byte_data(self.addr, cmd)\n\n# Read a block of data\n\ndef read_block_data(self, cmd):\n          return self.bus.read_block_data(self.addr, cmd)\n\n# commands\n\nLCD_CLEARDISPLAY = 0x01\n    LCD_RETURNHOME = 0x02\n    LCD_ENTRYMODESET = 0x04\n    LCD_DISPLAYCONTROL = 0x08\n    LCD_CURSORSHIFT = 0x10\n    LCD_FUNCTIONSET = 0x20\n    LCD_SETCGRAMADDR = 0x40\n    LCD_SETDDRAMADDR = 0x80\n\n# flags for display entry mode\n\nLCD_ENTRYRIGHT = 0x00\n    LCD_ENTRYLEFT = 0x02\n    LCD_ENTRYSHIFTINCREMENT = 0x01\n    LCD_ENTRYSHIFTDECREMENT = 0x00\n\n# flags for display on\/off control\n\nLCD_DISPLAYON = 0x04\n    LCD_DISPLAYOFF = 0x00\n    LCD_CURSORON = 0x02\n    LCD_CURSOROFF = 0x00\n    LCD_BLINKON = 0x01\n    LCD_BLINKOFF = 0x00\n\n# flags for display\/cursor shift\n\nLCD_DISPLAYMOVE = 0x08\n    LCD_CURSORMOVE = 0x00\n    LCD_MOVERIGHT = 0x04\n    LCD_MOVELEFT = 0x00\n\n# flags for function set",
                "char_count": 1133,
                "token_estimate": 284
            },
            {
                "title": "D-0006",
                "rev_id": 10821,
                "heading_path": "Demo Code For Handle PCF8574T > Python Demo Code",
                "chunk_index": 12,
                "content": "LCD_8BITMODE = 0x10\n    LCD_4BITMODE = 0x00\n    LCD_2LINE = 0x08\n    LCD_1LINE = 0x00\n    LCD_5x10DOTS = 0x04\n    LCD_5x8DOTS = 0x00\n\n# flags for backlight control\n\nLCD_BACKLIGHT = 0x08\n    LCD_NOBACKLIGHT = 0x00\n\nEn = 0b00000100 # Enable bit\n\nRw = 0b00000010 # Read\/Write bit\n\nRs = 0b00000001 # Register select bit\n\nclass lcd:\n       #initializes objects and lcd\n       def (self):\n          self.lcd_device = i2c_device(ADDRESS)\n\nself.lcd_write(0x03)\n          self.lcd_write(0x03)\n          self.lcd_write(0x03)\n          self.lcd_write(0x02)\n\nself.lcd_write(LCD_FUNCTIONSET | LCD_2LINE | LCD_5x8DOTS | LCD_4BITMODE)\n          self.lcd_write(LCD_DISPLAYCONTROL | LCD_DISPLAYON)\n          self.lcd_write(LCD_CLEARDISPLAY)\n          self.lcd_write(LCD_ENTRYMODESET | LCD_ENTRYLEFT)\n          sleep(0.2)\n\n# clocks EN to latch command\n\ndef lcd_strobe(self, data):\n          self.lcd_device.write_cmd(data | En | LCD_BACKLIGHT)\n          sleep(.0005)\n          self.lcd_device.write_cmd(((data & ~En) | LCD_BACKLIGHT))\n          sleep(.0001)\n\ndef lcd_write_four_bits(self, data):\n          self.lcd_device.write_cmd(data | LCD_BACKLIGHT)\n          self.lcd_strobe(data)\n\n# write a command to lcd",
                "char_count": 1193,
                "token_estimate": 299
            },
            {
                "title": "D-0006",
                "rev_id": 10821,
                "heading_path": "Demo Code For Handle PCF8574T > Python Demo Code",
                "chunk_index": 13,
                "content": "def lcd_write(self, cmd, mode=0):\n          self.lcd_write_four_bits(mode | (cmd & 0xF0))\n          self.lcd_write_four_bits(mode | ((cmd << 4) & 0xF0))\n\n# write a character to lcd (or character rom) 0x09: backlight | RS=DR<\n\n# works!\n\ndef lcd_write_char(self, charvalue, mode=1):\n          self.lcd_write_four_bits(mode | (charvalue & 0xF0))\n          self.lcd_write_four_bits(mode | ((charvalue << 4) & 0xF0))\n\n# put string function with optional char positioning\n\ndef lcd_display_string(self, string, line=1, pos=0):\n        if line == 1:\n          pos_new = pos\n        elif line == 2:\n          pos_new = 0x40 + pos\n        elif line == 3:\n          pos_new = 0x14 + pos\n        elif line == 4:\n          pos_new = 0x54 + pos\n\nself.lcd_write(0x80 + pos_new)\n\nfor char in string:\n          self.lcd_write(ord(char), Rs)\n\n# clear lcd and set to home\n\ndef lcd_clear(self):\n          self.lcd_write(LCD_CLEARDISPLAY)\n          self.lcd_write(LCD_RETURNHOME)\n\n# define backlight on\/off (lcd.backlight(1); off= lcd.backlight(0)\n\ndef backlight(self, state): # for state, 1 = on, 0 = off",
                "char_count": 1084,
                "token_estimate": 271
            },
            {
                "title": "D-0006",
                "rev_id": 10821,
                "heading_path": "Demo Code For Handle PCF8574T > Python Demo Code",
                "chunk_index": 14,
                "content": "if state == 1:\n             self.lcd_device.write_cmd(LCD_BACKLIGHT)\n          elif state == 0:\n             self.lcd_device.write_cmd(LCD_NOBACKLIGHT)\n\n# add custom characters (0 - 7)\n\ndef lcd_load_custom_chars(self, fontdata):\n          self.lcd_write(0x40);\n          for char in fontdata:\n             for line in char:\n                self.lcd_write_char(line)\n\n-   Create a file named: lcd1602.py and paste following code:\n\n<!-- -->\n\nimport I2C_LCD_driver\n    from time import *\n\nmylcd = I2C_LCD_driver.lcd()\n    # There are 16 character that you can put on the screen and 2 lines avaliable.\n\nmylcd.lcd_display_string(\"00000000000000000\", 1, 0)\n    mylcd.lcd_display_string(\"00000000000000000\", 2, 0)\n\n-   Run it.\n\n<!-- -->\n\npython lcd1602.py",
                "char_count": 748,
                "token_estimate": 187
            },
            {
                "title": "D-0006",
                "rev_id": 10821,
                "heading_path": "Application Scenario",
                "chunk_index": 15,
                "content": "-   Control-Any-Devices-Using-Raspberry-PI-and-PCF8574: \\[ <https:\/\/www.instructables.com\/id\/Control-Any-Devices-Using-Raspberry-PI-and-PCF8574\/> \\]\n-   I2C-1602-LCD: [1](https:\/\/github.com\/VeggieVampire\/I2C-1602-LCD)",
                "char_count": 217,
                "token_estimate": 55
            },
            {
                "title": "D-0006",
                "rev_id": 10821,
                "heading_path": "Keywords",
                "chunk_index": 16,
                "content": "-   PCF8574T, LCD1602, driver board, LCD driver board",
                "char_count": 53,
                "token_estimate": 14
            }
        ]
    }
}