{
    "ok": true,
    "data": {
        "title": "NightLight_Hat_Board_For_Raspberry_Pi_SKU:_EP-0098",
        "rev_id": 4477,
        "updated_at": "2019-06-06T07:02:35+00:00",
        "chunk_count": 16,
        "chunks": [
            {
                "title": "NightLight_Hat_Board_For_Raspberry_Pi_SKU:_EP-0098",
                "rev_id": 4477,
                "heading_path": "",
                "chunk_index": 0,
                "content": "# NightLight Hat Board For Raspberry Pi SKU: EP-0098",
                "char_count": 52,
                "token_estimate": 13
            },
            {
                "title": "NightLight_Hat_Board_For_Raspberry_Pi_SKU:_EP-0098",
                "rev_id": 4477,
                "heading_path": "NightLight Hat Board For Raspberry Pi",
                "chunk_index": 1,
                "content": "<figure>\n<img src=\"Nlddl01.jpg\" title=\"Nlddl01.jpg\" width=\"300\" alt=\"Nlddl01.jpg\" \/>\n<figcaption aria-hidden=\"true\">Nlddl01.jpg<\/figcaption>\n<\/figure>",
                "char_count": 150,
                "token_estimate": 38
            },
            {
                "title": "NightLight_Hat_Board_For_Raspberry_Pi_SKU:_EP-0098",
                "rev_id": 4477,
                "heading_path": "Description",
                "chunk_index": 2,
                "content": "NightLight Hat Board For Raspberry Pi is a Hat Board which have 8 WS2812 RGB LED lights.\nAnd this Hat Board will communicate with Raspberry Pi via I2C protocol.\nYou can control each LED's color individually by command.\nAt the same time, you can also adjust the brightness of each LED by command.\nThe light board is connected to the GPIO pin by HAT.\nYou can stack multiple identical boards in a layered manner, which can make your lighting more layered.\nIt is recommended not to exceed four layers at most. Otherwise, the power supply may be insufficient.\nBecause all the lights need to be powered from the GPIO pin of the Raspberry Pi.\nThe feature of the HAT board is that you don't have to worry about messy cables.\nIf you only use one layer of light board, you can engrave your favorite pattern on an acrylic board with a laser engraving machine,\nand then insert it vertically into the random acrylic bracket,\nso that by controlling the light, you can make different The acrylic art board presents a different brilliance, turning your light board into a work of art.",
                "char_count": 1068,
                "token_estimate": 267
            },
            {
                "title": "NightLight_Hat_Board_For_Raspberry_Pi_SKU:_EP-0098",
                "rev_id": 4477,
                "heading_path": "Features",
                "chunk_index": 3,
                "content": "<figure>\n<img src=\"Nlddl06.jpg\" title=\"Nlddl06.jpg\" width=\"300\" alt=\"Nlddl06.jpg\" \/>\n<figcaption aria-hidden=\"true\">Nlddl06.jpg<\/figcaption>\n<\/figure>\n\n-   Easy to setup\n-   WS2812 RGB LEDs\n-   Extend the GPIO Pins\n-   Can be mounted on top of the stack\n-   Can Stack with other Stack board such as Relay module\n-   Individual control of each Light\n-   With beautiful acrylic light guide,Two factory-made patterns, two of them are blank for you DIY\n-   Plug and Play\n-   One command control\n-   Multiple Programming Language support such as shell, python, C\/C++ and so on",
                "char_count": 571,
                "token_estimate": 143
            },
            {
                "title": "NightLight_Hat_Board_For_Raspberry_Pi_SKU:_EP-0098",
                "rev_id": 4477,
                "heading_path": "Compatibility List",
                "chunk_index": 4,
                "content": "-   Compatibility\n\n| Platform                    | Nightlight Hat board | Notes |\n|-----------------------------|----------------------|-------|\n| Raspberry Pi 3 Model A Plus | √                    |       |\n| Raspberry Pi 3 Model B Plus | √                    |       |\n| Raspberry Pi zero           | √                    |       |\n| Raspberry Pi zero W         | √                    |       |\n| Raspberry Pi 3 Model B      | √                    |       |\n| Raspberry Pi 2 Model B      | √                    |       |\n| Raspberry Pi Model B+       | √                    |       |\n|                             |                      |       |",
                "char_count": 648,
                "token_estimate": 162
            },
            {
                "title": "NightLight_Hat_Board_For_Raspberry_Pi_SKU:_EP-0098",
                "rev_id": 4477,
                "heading_path": "Gallery",
                "chunk_index": 5,
                "content": "|                                              |                                              |                                              |\n|----------------------------------------------|----------------------------------------------|----------------------------------------------|\n| ![ 300px\\| left](Nlddl02.jpg \" 300px| left\") | ![ 300px\\| none](Nlddl03.jpg \" 300px| none\") | ![ 300px\\| none](Nlddl04.jpg \" 300px| none\") |\n\n------------------------------------------------------------------------\n\n|                                              |                                              |                                              |\n|----------------------------------------------|----------------------------------------------|----------------------------------------------|\n| ![ 300px\\| left](Nlddl01.jpg \" 300px| left\") | ![ 300px\\| none](Nlddl05.jpg \" 300px| none\") | ![ 300px\\| none](Nlddl07.jpg \" 300px| none\") |",
                "char_count": 932,
                "token_estimate": 233
            },
            {
                "title": "NightLight_Hat_Board_For_Raspberry_Pi_SKU:_EP-0098",
                "rev_id": 4477,
                "heading_path": "Package Includes",
                "chunk_index": 6,
                "content": "<img src=\"Nlddl08.jpg\" title=\"Nlddl08.jpg\" width=\"300\" alt=\"Nlddl08.jpg\" \/>\n\\* 1 x NightLight Hat Board For Raspberry Pi\n\n-   4 x M2.5x12 copper sticks\n-   4 x M2.5x6 screws (Botton)\n-   4 x M2.5x10 screws (Top)\n-   1 x Acrylic Pattern Design (Stander)\n-   4 x Acrylic Pattern Design (2x Caved and 2x blank)",
                "char_count": 307,
                "token_estimate": 77
            },
            {
                "title": "NightLight_Hat_Board_For_Raspberry_Pi_SKU:_EP-0098",
                "rev_id": 4477,
                "heading_path": "How to use it",
                "chunk_index": 7,
                "content": "-   Turn on the I2C interface\n\nOpen a terminal and Run sudo raspi-config\nUse the down arrow to select 5 Interfacing Options.\nArrow down to P5 I2C .\nSelect yes when it asks you to enable I2C.\nAlso select yes if it asks about automatically loading the kernel module.\nUse the right arrow to select the <Finish> button.\nSelect yes when it asks to reboot.\n\\* Detect the register of the chip on board `i2cdetect -y 1`\nyou will see this result: <img src=\"Nightlighti2c09.png\" title=\"Nightlighti2c09.png\" width=\"300\" alt=\"Nightlighti2c09.png\" \/>\n\\* Lights up one LED `i2cset -y 1 0x15 0x01 0xff`\n\n     The first parameter \"0x15\" means the address of Nightlight hat.\n    \"0x01\" means the first LED's red color, every LED\n    has a register address, and you can follow this chart, \"0xff\" means give the LED 100% brightness\n    and \"0x00\" will turn of the LED, you can put the value from \"0x00\" to \"0xff\" to make a dim LED",
                "char_count": 911,
                "token_estimate": 228
            },
            {
                "title": "NightLight_Hat_Board_For_Raspberry_Pi_SKU:_EP-0098",
                "rev_id": 4477,
                "heading_path": "Register Map",
                "chunk_index": 8,
                "content": "| Register Number | Color       | Mark                                         |\n|-----------------|-------------|----------------------------------------------|\n| 0x01            | red color   | No.1 LED                                     |\n| 0x02            | green color | No.1 LED                                     |\n| 0x03            | blue color  | No.1 LED                                     |\n| 0x04            | red color   | No.2 LED                                     |\n| 0x05            | green color | No.2 LED                                     |\n| 0x06            | blue color  | No.2 LED                                     |\n| 0x07            | red color   | No.3 LED                                     |\n| 0x08            | green color | No.3 LED                                     |\n| 0x09            | blue color  | No.3 LED                                     |\n| 0x0a            | red color   | No.4 LED                                     |\n| 0x0b            | green color | No.4 LED                                     |\n| 0x0c            | blue color  | No.4 LED                                     |\n| 0x0d            | red color   | No.",
                "char_count": 1171,
                "token_estimate": 293
            },
            {
                "title": "NightLight_Hat_Board_For_Raspberry_Pi_SKU:_EP-0098",
                "rev_id": 4477,
                "heading_path": "Register Map",
                "chunk_index": 9,
                "content": "5 LED                                     |\n| 0x0e            | green color | No.5 LED                                     |\n| 0x0f            | blue color  | No.5 LED                                     |\n| 0x10            | red color   | No.6 LED                                     |\n| 0x11            | green color | No.6 LED                                     |\n| 0x12            | blue color  | No.6 LED                                     |\n| 0x13            | red color   | No.7 LED                                     |\n| 0x14            | green color | No.7 LED                                     |\n| 0x15            | blue color  | No.7 LED                                     |\n| 0x16            | red color   | No.8 LED                                     |\n| 0x17            | green color | No.8 LED                                     |\n| 0x18            | blue color  | No.8 LED                                     |\n| 0x19            | button      | 0x01 - Button Pressed 0x00 - Button Released |",
                "char_count": 1015,
                "token_estimate": 254
            },
            {
                "title": "NightLight_Hat_Board_For_Raspberry_Pi_SKU:_EP-0098",
                "rev_id": 4477,
                "heading_path": "Example Demo",
                "chunk_index": 10,
                "content": "-   Shell script\n\nsimple script to light up all LED's individually in a loop.\n\n#!\/bin\/bash\n    # lights up each LED individually in a loop.\n\n#!\/bin\/bash\n    #\n\nLED_array=(0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0a 0x0b 0x0c 0x0d 0x0e 0x0f 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18)\n    while true\n    do\n            for i in `seq 0 24`\n            do\n                    i2cset -y 1 0x15 ${LED_array[i]} 0xFF   # turn on the led\n\nsleep 0.5                               # delay\n\ni2cset -y 1 0x15 ${LED_array[i]} 0x00   # turn of the led\n\nsleep 0.5                               # delay\n\ndone\n    done\n\nsave this script in a file named \"nightlight.sh\" and then give it executive permission:\n`chmod +x nightlight.sh`\n`sudo .\/nightlight.sh`\n----\n\n-   Test DEMO in Language C\n\nPlease make sure your Raspberry Pi has been already connected to internet\nIn this demo, please make sure you have installed wiringPi library before you compile this C code.\n\nsudo apt-get update\n    sudo apt-get -y install git-core\n    cd\n    git clone git:\/\/git.drogon.net\/wiringPi\n    cd ~\/wiringPi\n    git pull origin\n    cd ~\/wiringPi\n    .\/build\n\n-   -   Test wiringPi’s installation",
                "char_count": 1170,
                "token_estimate": 293
            },
            {
                "title": "NightLight_Hat_Board_For_Raspberry_Pi_SKU:_EP-0098",
                "rev_id": 4477,
                "heading_path": "Example Demo",
                "chunk_index": 11,
                "content": "run the gpio command to check the installation:\n\ngpio -v\n    gpio readall\n\nThat should give you some confidence that it’s working OK.\nAnd then create a file called \"nightlight.c\" and write following code：\n\n#include <stdio.h>\n    #include <wiringPi.h>\n    #include <wiringPiI2C.h>\n\n#define BUTTON_REG_ADDR 0x19\n\nint main(){\n            int fd;\n            int is_press = 1;\n            int is_draw = 0;\n            int i = 0;\n\nfd = wiringPiI2CSetup(0x15);\n\nfor(i = 1;i<25;i++) wiringPiI2CWriteReg8(fd,i,0x00);",
                "char_count": 508,
                "token_estimate": 127
            },
            {
                "title": "NightLight_Hat_Board_For_Raspberry_Pi_SKU:_EP-0098",
                "rev_id": 4477,
                "heading_path": "Example Demo",
                "chunk_index": 12,
                "content": "for(;;)\n            {\n                    if (wiringPiI2CReadReg8(fd, BUTTON_REG_ADDR) == 0x01 )\n                    {\n                            is_press++;\n                            is_draw = 1;\n                            wiringPiI2CWriteReg8(fd,BUTTON_REG_ADDR, 0x0);\n                    }\n                    if(is_press && is_draw){\n                            is_draw = 0;\n                            for(i = 1;i<25;i++){\n                                    if(is_press > 3) is_press = 1;\n                                    if(((i + is_press) % 3) == 0)\n                                    {\n                                            wiringPiI2CWriteReg8(fd,i,0xff);\n                                    }else{\n                                            wiringPiI2CWriteReg8(fd,i,0x00);\n                                    }\n                                    delay(100);\n                            }\n\nwiringPiI2CWriteReg8(fd,BUTTON_REG_ADDR, 0x0);\n                    }\n            }\n    }\n\nsave it and then compile it by this command:\n`gcc nightlight.c -lwiringPi -o nightlight`\nrun it:\n`sudo .\/nightlight`\n----\n\n-   Python script",
                "char_count": 1147,
                "token_estimate": 287
            },
            {
                "title": "NightLight_Hat_Board_For_Raspberry_Pi_SKU:_EP-0098",
                "rev_id": 4477,
                "heading_path": "Example Demo",
                "chunk_index": 13,
                "content": "you can also use Python script to driver the board.\nfirst, make sure you have installed \"smbus2\" library.\nif not, please open a terminal and input python and then:\n`sudo pip3 install smbus2`\nand then Create a new file named \" nightlight.py\" and copy and paste this code:\n\n#!\/usr\/bin\/env python\n    #\n    import time as t\n    import smbus\n\nDEVICE_BUS = 1\n    DEVICE_ADDR = 0x15\n    bus = smbus.SMBus(DEVICE_BUS)\n\nwhile True:\n        try:\n            for i in range(1,25):\n                bus.write_byte_data(DEVICE_ADDR, i, 0xFF)\n                t.sleep(0.2)\n                bus.write_byte_data(DEVICE_ADDR, i, 0x00)\n                t.sleep(0.2)\n        except KeyboardInterrupt as e:\n            print(\"Quit the Loop\")\n\nsave it and run: `python nightlight.py`\n----",
                "char_count": 764,
                "token_estimate": 191
            },
            {
                "title": "NightLight_Hat_Board_For_Raspberry_Pi_SKU:_EP-0098",
                "rev_id": 4477,
                "heading_path": "Keywords",
                "chunk_index": 14,
                "content": "-   nightlight, dockerpi, raspberry pi, light, i2c, smbus2, iot",
                "char_count": 63,
                "token_estimate": 16
            },
            {
                "title": "NightLight_Hat_Board_For_Raspberry_Pi_SKU:_EP-0098",
                "rev_id": 4477,
                "heading_path": "Video Tutorial",
                "chunk_index": 15,
                "content": "<img src=\"Youtube.jpeg\" title=\"Youtube.jpeg\" width=\"200\" alt=\"Youtube.jpeg\" \/>\n\\* Please follow the link:\n\n-   \\[ DockerPi NightLight Board Tutorial\\| <https:\/\/youtu.be\/KI7cQQLffG0> \\]",
                "char_count": 184,
                "token_estimate": 46
            }
        ]
    }
}