{
    "ok": true,
    "data": {
        "title": "EP-0249",
        "rev_id": 15732,
        "updated_at": "2025-02-19T03:53:04+00:00",
        "chunk_count": 33,
        "chunks": [
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "",
                "chunk_index": 0,
                "content": "# EP-0249",
                "char_count": 9,
                "token_estimate": 3
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "4 USB-Channel 5V Power supply module",
                "chunk_index": 1,
                "content": "<figure>\n<img src=\"EP-0249-1.jpg\" title=\"EP-0249-1.jpg\" width=\"320\" alt=\"EP-0249-1.jpg\" \/>\n<figcaption aria-hidden=\"true\">EP-0249-1.jpg<\/figcaption>\n<\/figure>",
                "char_count": 158,
                "token_estimate": 40
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "Description",
                "chunk_index": 2,
                "content": "The PowerHub 4 USB-Channel 5V Power Supply module is an advanced power management module designed for versatile applications. It features a robust metal casing that ensures durability and protection. This module is not only a standalone power solution but also integrates seamlessly with DeskPi's Rackmate T0 or Rackmate T1 enclosures, making it suitable for 1U rack mounting. This allows for a unified power supply management system in a rack environment.",
                "char_count": 456,
                "token_estimate": 114
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "Features",
                "chunk_index": 3,
                "content": "-   <strong>Metal Casing:<\/strong> Provides a sturdy and protective shell for the power module.\n-   <strong>RackMount Compatibility:<\/strong> Can be integrated into a 1U rack system using DeskPi's Rackmate T0 or T1 enclosures.\n-   <strong>2-Channel Power Distribution:<\/strong> Capable of handling multiple devices with a maximum output of 8A in total.\n-   <strong>Dual USB Ports per Channel:<\/strong> Each channel features two USB ports sharing a maximum current of 8A.\n-   <strong>INA3221 Monitoring:<\/strong> Utilizes two INA3221 chips for precise voltage and current detection.\n-   <strong>OLED Display Interface:<\/strong> Equipped with a 0.91-inch OLED screen for displaying power output information.\n-   <strong>Raspberry Pi Pico Compatibility:<\/strong> Designed to work with a Raspberry Pi Pico for advanced control and customization through I2C communication.\n-   <strong>Programmable Output Information:<\/strong> Customizable display content through MicroPython scripting or C++ SDK.\n-   <strong>Wide Input Voltage Range:<\/strong> Accepts a wide range of input voltages from 6V to 24V.",
                "char_count": 1094,
                "token_estimate": 274
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "Features > Specifications",
                "chunk_index": 4,
                "content": "-   <strong>Input Voltage:<\/strong> 6-24V DC，The inner diameter of the DC port: 5.44mm\n-   <strong>Maximum Current:<\/strong> 8A per channel (Shared by 4 x USB ports)\n-   <strong>Output Channels:<\/strong> 2 channels with dual USB ports each, totaling 4 USB ports\n-   <strong>Monitoring Chips:<\/strong> Two INA3221 chips for voltage and current monitoring\n-   <strong>Display:<\/strong> 0.91-inch OLED screen for real-time power output information. Default I2C address: 0x3c\n-   <strong>Control Interface:<\/strong> I2C interface for communication with Raspberry Pi Pico\n-   <strong>Programming:<\/strong> Supports MicroPython for scripting and C++ SDK for advanced customization\n-   <strong>Safety Features:<\/strong> Built-in protection mechanisms to prevent overcurrent and overheating\n-   <strong>Metal Casing:<\/strong>Adds to the durability and allows for rack mounting\n-   <strong>RackMount Compatibility:<\/strong> Compatible with DeskPi Rackmate T0 or T1 for 1U rack mounting\n-   <strong>Shunt Resister:<\/strong> 6mR\n-   <strong>Dimensions:<\/strong> 90mm x 88mm x 45mm\n-   <strong>Weight:<\/strong> 0.155kg",
                "char_count": 1106,
                "token_estimate": 277
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "Gallery",
                "chunk_index": 5,
                "content": "-   Product Outlook",
                "char_count": 19,
                "token_estimate": 5
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "Gallery",
                "chunk_index": 6,
                "content": "<img src=\"EP-0249-1.jpg\" title=\"EP-0249-1.jpg\" width=\"800\" alt=\"EP-0249-1.jpg\" \/>\n\\* Frontal face outlook <img src=\"EP-0249-2.jpg\" title=\"EP-0249-2.jpg\" width=\"800\" alt=\"EP-0249-2.jpg\" \/>\n\\* Product details <img src=\"EP-0249-3.jpg\" title=\"EP-0249-3.jpg\" width=\"800\" alt=\"EP-0249-3.jpg\" \/>\n<img src=\"EP-0249-8.jpg\" title=\"EP-0249-8.jpg\" width=\"800\" alt=\"EP-0249-8.jpg\" \/>\n\\* Dimension <img src=\"EP-0249-4.jpg\" title=\"EP-0249-4.jpg\" width=\"800\" alt=\"EP-0249-4.jpg\" \/>\n\\* Aluminum Passive Heat dissipation heat-sink <img src=\"EP-0249-5.jpg\" title=\"EP-0249-5.jpg\" width=\"800\" alt=\"EP-0249-5.jpg\" \/>\n\\* Pico main controller support MicroPython reprogrammable and C++ SDK <img src=\"EP-0249-6.jpg\" title=\"EP-0249-6.jpg\" width=\"800\" alt=\"EP-0249-6.jpg\" \/>\n\\* Open-Source Design <img src=\"EP-0249-7.jpg\" title=\"EP-0249-7.jpg\" width=\"800\" alt=\"EP-0249-7.jpg\" \/>\n\\* Application scenario <img src=\"EP-0249-9.jpg\" title=\"EP-0249-9.jpg\" width=\"800\" alt=\"EP-0249-9.jpg\" \/>\n\\* Compatiable with DeskPi Rackmate's rack mount <img src=\"EP-0249-10.jpg\" title=\"EP-0249-10.jpg\" width=\"800\" alt=\"EP-0249-10.jpg\" \/>\n\\* Circuit Schema Drawing <img src=\"Schema-circuit.png\" title=\"Schema-circuit.",
                "char_count": 1170,
                "token_estimate": 293
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "Gallery",
                "chunk_index": 7,
                "content": "png\" width=\"800\" alt=\"Schema-circuit.png\" \/>\n==Package Includes==",
                "char_count": 65,
                "token_estimate": 17
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "Gallery",
                "chunk_index": 8,
                "content": "-   Package includes\n\n<img src=\"EP-0249-11.jpg\" title=\"EP-0249-11.jpg\" width=\"800\" alt=\"EP-0249-11.jpg\" \/>",
                "char_count": 106,
                "token_estimate": 27
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "How to install or update MicroPython firmware?",
                "chunk_index": 9,
                "content": "-   Download \\`Thonny IDE\\` software from internet and install it on your computer.\n-   \\[Download Thonny IDE <https:\/\/thonny.org\/>\\]",
                "char_count": 133,
                "token_estimate": 34
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "How to install or update MicroPython firmware?",
                "chunk_index": 10,
                "content": "<img src=\"Download_thonny_ide.png\" title=\"Download_thonny_ide.png\" width=\"800\" alt=\"Download_thonny_ide.png\" \/>\n<img src=\"Download_for_windows.png\" title=\"Download_for_windows.png\" width=\"800\" alt=\"Download_for_windows.png\" \/>\n\\* Please install it as following figures. <img src=\"Thonny_installation-01.png\" title=\"Thonny_installation-01.png\" width=\"800\" alt=\"Thonny_installation-01.png\" \/>\n<img src=\"Thonny_installation-02.png\" title=\"Thonny_installation-02.png\" width=\"800\" alt=\"Thonny_installation-02.png\" \/>\n<img src=\"Thonny_installation-03.png\" title=\"Thonny_installation-03.png\" width=\"800\" alt=\"Thonny_installation-03.png\" \/>\n<img src=\"Thonny_installation-04.png\" title=\"Thonny_installation-04.png\" width=\"800\" alt=\"Thonny_installation-04.png\" \/>\n<img src=\"Thonny_installation-05.png\" title=\"Thonny_installation-05.png\" width=\"800\" alt=\"Thonny_installation-05.png\" \/>\n<img src=\"Thonny_installation-06.png\" title=\"Thonny_installation-06.png\" width=\"800\" alt=\"Thonny_installation-06.png\" \/>\n<img src=\"Thonny_installation-07.png\" title=\"Thonny_installation-07.png\" width=\"800\" alt=\"Thonny_installation-07.png\" \/>\n=== How to read the voltage and current? ===\n\nSupport MicroPython Only right now",
                "char_count": 1197,
                "token_estimate": 300
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "How to install or update MicroPython firmware?",
                "chunk_index": 11,
                "content": "-   Install micropython firmware Steps\n\n1\\. Put your device into bootloader mode: Device have to be plugged in while holding the \\`BOOTSEL\\` button. 2. Wait for couple of seconds until the target volume appears. 3. Select desired variant and version. 4. Click \\`install\\` and wait for some seconds until done. 5. Close the dialog and start programming!",
                "char_count": 352,
                "token_estimate": 88
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "How to install or update MicroPython firmware? > Install microPython firmware",
                "chunk_index": 12,
                "content": "-   Open thonny IDE and Click \\`run\\` and \\`configure interpreter\\`，select \\`MicroPython (Raspberry Pi Pico)\\`",
                "char_count": 110,
                "token_estimate": 28
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "How to install or update MicroPython firmware? > Install microPython firmware",
                "chunk_index": 13,
                "content": "<img src=\"Install_Micropython_firmware_01.png\" title=\"Install_Micropython_firmware_01.png\" width=\"800\" alt=\"Install_Micropython_firmware_01.png\" \/>\n\\* Click \\`install or update MicroPython\\` and then follow following figures: <img src=\"Install_Micropython_firmware_02.png\" title=\"Install_Micropython_firmware_02.png\" width=\"800\" alt=\"Install_Micropython_firmware_02.png\" \/>\n<img src=\"Install_Micropython_firmware_03.png\" title=\"Install_Micropython_firmware_03.png\" width=\"800\" alt=\"Install_Micropython_firmware_03.png\" \/>\n<img src=\"Install_Micropython_firmware_04.png\" title=\"Install_Micropython_firmware_04.png\" width=\"800\" alt=\"Install_Micropython_firmware_04.png\" \/>\n<img src=\"Install_Micropython_firmware_05.png\" title=\"Install_Micropython_firmware_05.png\" width=\"800\" alt=\"Install_Micropython_firmware_05.png\" \/>\n<img src=\"Install_Micropython_firmware_06.png\" title=\"Install_Micropython_firmware_06.png\" width=\"800\" alt=\"Install_Micropython_firmware_06.png\" \/>\nReopen the menu by click \\`run\\` and \\`configure interpreter\\`, select the right serial port for programming, here is mine: <img src=\"Install_Micropython_firmware_07.png\" title=\"Install_Micropython_firmware_07.",
                "char_count": 1176,
                "token_estimate": 294
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "How to install or update MicroPython firmware? > Install microPython firmware",
                "chunk_index": 14,
                "content": "png\" width=\"800\" alt=\"Install_Micropython_firmware_07.png\" \/>",
                "char_count": 61,
                "token_estimate": 16
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "How to install or update MicroPython firmware? > Upload dependencies libraries",
                "chunk_index": 15,
                "content": "-   INA3221.py\n\nOpen a new file, copy and paste following code, and the library file can be found below 'ina3221.zip' file,should be unzipped before using. if you use copy-paste way, please name it to \\`ina3221.py\\` <img src=\"Install_Micropython_firmware_08.png\" title=\"Install_Micropython_firmware_08.png\" width=\"800\" alt=\"Install_Micropython_firmware_08.png\" \/>\n\nfrom machine import I2C, Pin, Timer\n    from micropython import const\n    import time\n\n_REG_CONFIG                      = const(0x00)\n\n_RESET                           = const(0x8000)\n    _ENABLE_CH                       = (None,const(0x4000),const(0x2000),const(0x1000)) # default set\n\n_AVERAGING_MASK                  = const(0x0E00)\n    _AVERAGING_NONE                  = const(0x0000)     # 1 sample, default\n\n_AVERAGING_4_SAMPLES             = const(0x0200)\n    _AVERAGING_16_SAMPLES            = const(0x0400)\n    _AVERAGING_64_SAMPLES            = const(0x0600)\n    _AVERAGING_128_SAMPLES           = const(0x0800)\n    _AVERAGING_256_SAMPLES           = const(0x0A00)\n    _AVERAGING_512_SAMPLES           = const(0x0C00)\n    _AVERAGING_1024_SAMPLES          = const(0x0E00)",
                "char_count": 1145,
                "token_estimate": 287
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "How to install or update MicroPython firmware? > Upload dependencies libraries",
                "chunk_index": 16,
                "content": "_VBUS_CONV_TIME_MASK             = const(0x01C0)\n    _VBUS_CONV_TIME_140US            = const(0x0000)\n    _VBUS_CONV_TIME_204US            = const(0x0040)\n    _VBUS_CONV_TIME_332US            = const(0x0080)\n    _VBUS_CONV_TIME_588US            = const(0x00C0)\n    _VBUS_CONV_TIME_1MS              = const(0x0100)     # 1.1ms, default\n\n_VBUS_CONV_TIME_2MS              = const(0x0140)     # 2.116ms\n\n_VBUS_CONV_TIME_4MS              = const(0x0180)     # 4.156ms\n\n_VBUS_CONV_TIME_8MS              = const(0x01C0)     # 8.244ms\n\n_SHUNT_CONV_TIME_MASK            = const(0x0038)\n    _SHUNT_CONV_TIME_140US           = const(0x0000)\n    _SHUNT_CONV_TIME_204US           = const(0x0008)\n    _SHUNT_CONV_TIME_332US           = const(0x0010)\n    _SHUNT_CONV_TIME_588US           = const(0x0018)\n    _SHUNT_CONV_TIME_1MS             = const(0x0020)     # 1.1ms, default\n\n_SHUNT_CONV_TIME_2MS             = const(0x0028)     # 2.116ms\n\n_SHUNT_CONV_TIME_4MS             = const(0x0030)     # 4.156ms\n\n_SHUNT_CONV_TIME_8MS             = const(0x0038)     # 8.244ms\n\n_MODE_MASK                       = const(0x0007)\n    _MODE_POWER_DOWN                 = const(0x0000)     # Power-down",
                "char_count": 1174,
                "token_estimate": 294
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "How to install or update MicroPython firmware? > Upload dependencies libraries",
                "chunk_index": 17,
                "content": "_MODE_SHUNT_VOLTAGE_TRIGGERED    = const(0x0001)     # Shunt voltage, single-shot (triggered)\n\n_MODE_BUS_VOLTAGE_TRIGGERED      = const(0x0002)     # Bus voltage, single-shot (triggered)\n\n_MODE_SHUNT_AND_BUS_TRIGGERED    = const(0x0003)     # Shunt and bus, single-shot (triggered)\n\n_MODE_POWER_DOWN2                = const(0x0004)     # Power-down\n\n_MODE_SHUNT_VOLTAGE_CONTINUOUS   = const(0x0005)     # Shunt voltage, continous\n\n_MODE_BUS_VOLTAGE_CONTINUOUS     = const(0x0006)     # Bus voltage, continuous\n\n_MODE_SHUNT_AND_BUS_CONTINOUS    = const(0x0007)     # Shunt and bus, continuous (default)\n\n# Other registers\n\n_REG_SHUNT_VOLTAGE_CH            = (None, const(0x01), const(0x03), const(0x05))\n    _REG_BUS_VOLTAGE_CH              = (None, const(0x02), const(0x04), const(0x06))\n    _REG_CRITICAL_ALERT_LIMIT_CH     = (None, const(0x07), const(0x09), const(0x0B))\n    _REG_WARNING_ALERT_LIMIT_CH      = (None, const(0x08), const(0x0A), const(0x0C))\n    _REG_SHUNT_VOLTAGE_SUM           = const(0x0D)\n    _REG_SHUNT_VOLTAGE_SUM_LIMIT     = const(0x0E)\n\n# Mask\/enable register",
                "char_count": 1083,
                "token_estimate": 271
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "How to install or update MicroPython firmware? > Upload dependencies libraries",
                "chunk_index": 18,
                "content": "_REG_MASK_ENABLE                 = const(0x0F)\n    _SUM_CONTROL_CH                  = (None,const(0x4000),const(0x2000),const(0x1000)) #default not set\n    _WARNING_LATCH_ENABLE            = const(0x0800)     # default not set\n\n_CRITICAL_LATCH_ENABLE           = const(0x0400)     # default not set\n\n_CRITICAL_FLAG_CH                = (None,const(0x0200),const(0x0100),const(0x0080))\n    _SUM_ALERT_FLAG                  = const(0x0040)\n    _WARNING_FLAG_CH                 = (None,const(0x0020),const(0x0010),const(0x0008))\n    _POWER_ALERT_FLAG                = const(0x0004)\n    _TIMING_ALERT_FLAG               = const(0x0002)\n    _CONV_READY_FLAG                 = const(0x0001)\n\n# Other registers\n\n_REG_POWER_VALID_UPPER_LIMIT     = const(0x10)\n    _REG_POWER_VALID_LOWER_LIMIT     = const(0x11)\n    _REG_MANUFACTURER_ID             = const(0xFE)\n    _REG_DIE_ID                      = const(0xFF)\n\n# Constants for manufacturer and device ID\n\n_MANUFACTURER_ID                 = const(0x5449)     # \"TI\"\n\n_DIE_ID                          = const(0x3220)",
                "char_count": 1058,
                "token_estimate": 265
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "How to install or update MicroPython firmware? > Upload dependencies libraries",
                "chunk_index": 19,
                "content": "INA3221_I2C_ADDR = const(64)\n    INA3221_REG_MASK = const(0x0f)\n    INA3221_REG_ID = const(0xff)\n    #R_SHUNT = [100, 100, 100]\n    R_SHUNT = [0.006, 0.006, 0.006]\n\nclass INA3221:\n        def (self, i2c,addr = INA3221_I2C_ADDR):\n            self.addr = addr\n            self.i2c = i2c\n            self.buf = bytearray(2)\n        def getVShunt(self, chl_num = 0):\n            \"\"\"Get shunt resister voltage\"\"\"\n            reg = 1 + chl_num * 2\n            v_shunt_raw = self.i2c.readfrom_mem(self.addr, reg, 2)\n            return v_shunt_raw[0], v_shunt_raw[1]\n\ndef getIShunt(self, chl_num=0):\n            \"\"\"get chl_num current\"\"\"\n            v_shunt_raw = self.getVShunt(chl_num)\n            i_shunt = (v_shunt_raw[0] << 8) | v_shunt_raw[1]\n            if v_shunt & 0x8000:\n                v_shunt = -((~v_shunt +1 ) & 0xFFFF)\n            v_shunt = v_shunt * 40 \/ 1000000\n            i_shunt = v_shunt \/ R_SHUNT[chl_num]\n            return i_shunt\n\ndef getVBusRaw(self, chl_num = 0):\n            \"\"\"Get raw input voltage data\"\"\"\n            reg = (chl_num + 1)* 2\n            v_bus_raw = self.i2c.readfrom_mem(self.addr, reg, 2)\n            return v_bus_raw",
                "char_count": 1157,
                "token_estimate": 290
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "How to install or update MicroPython firmware? > Upload dependencies libraries",
                "chunk_index": 20,
                "content": "def getVBus(self, chl_num = 0):\n            \"\"\"Get Input voltage\"\"\"\n            v_bus_raw = self.getVBusRaw(chl_num)\n            v_bus = v_bus_raw[0]  * 256 + v_bus_raw[1]\n            return v_bus\n\ndef getIShunt(self, chl_num = 0):\n            \"\"\"Get chl_num current\"\"\"\n            v_shunt_raw = self.getVShunt(chl_num)\n            v_shunt = v_shunt_raw[1] * 5 + v_shunt_raw[0] * 1280\n            i_shunt = v_shunt \/ R_SHUNT[chl_num]\n            return i_shunt\n\ndef getI(self,chl_num=0,avg=20):\n            \"\"\"Get current，default 1ms get once，20ms detect the current, 0.02s detect once\"\"\"\n            a=0\n            for i in range(avg):\n                i_o=self.getIShunt(chl_num)\n                a=a + i_o\n                time.sleep_ms(1)\n            return round(a \/ avg, 1)\n\n-   Save it to Raspberry Pi Pico's \\`lib\\` folder",
                "char_count": 828,
                "token_estimate": 207
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "How to install or update MicroPython firmware? > Upload dependencies libraries",
                "chunk_index": 21,
                "content": "<img src=\"Install_Micropython_firmware_09.png\" title=\"Install_Micropython_firmware_09.png\" width=\"800\" alt=\"Install_Micropython_firmware_09.png\" \/>\n<img src=\"Install_Micropython_firmware_10.png\" title=\"Install_Micropython_firmware_10.png\" width=\"800\" alt=\"Install_Micropython_firmware_10.png\" \/>\nIf no \\`lib\\` folder, right click and create one. <img src=\"Install_Micropython_firmware_11.png\" title=\"Install_Micropython_firmware_11.png\" width=\"800\" alt=\"Install_Micropython_firmware_11.png\" \/>\n<img src=\"Install_Micropython_firmware_12.png\" title=\"Install_Micropython_firmware_12.png\" width=\"800\" alt=\"Install_Micropython_firmware_12.png\" \/>\nand then enter into the \\`lib\\` folder and save the library file as \\`ina3221.py\\`. <img src=\"Install_Micropython_firmware_13.png\" title=\"Install_Micropython_firmware_13.png\" width=\"800\" alt=\"Install_Micropython_firmware_13.png\" \/>\n\\* Download ina3221.py zipped file: <File:Ina3221.zip>\n\n-   Upload OLED driver \\`ssd1306.py\\`",
                "char_count": 967,
                "token_estimate": 242
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "How to install or update MicroPython firmware? > Upload dependencies libraries",
                "chunk_index": 22,
                "content": "This library is to light up 0.91 inch OLED display, please use the same way to upload the library. make sure it looks like this: <img src=\"Install_Micropython_firmware_14.png\" title=\"Install_Micropython_firmware_14.png\" width=\"800\" alt=\"Install_Micropython_firmware_14.png\" \/>\nFollowing is the content of \\`ssd1306.py\\` file.\n\n# MicroPython SSD1306 OLED driver, I2C and SPI interfaces\n\nfrom micropython import const\n    import framebuf\n\n# register definitions\n\nSET_CONTRAST = const(0x81)\n    SET_ENTIRE_ON = const(0xA4)\n    SET_NORM_INV = const(0xA6)\n    SET_DISP = const(0xAE)\n    SET_MEM_ADDR = const(0x20)\n    SET_COL_ADDR = const(0x21)\n    SET_PAGE_ADDR = const(0x22)\n    SET_DISP_START_LINE = const(0x40)\n    SET_SEG_REMAP = const(0xA0)\n    SET_MUX_RATIO = const(0xA8)\n    SET_COM_OUT_DIR = const(0xC0)\n    SET_DISP_OFFSET = const(0xD3)\n    SET_COM_PIN_CFG = const(0xDA)\n    SET_DISP_CLK_DIV = const(0xD5)\n    SET_PRECHARGE = const(0xD9)\n    SET_VCOM_DESEL = const(0xDB)\n    SET_CHARGE_PUMP = const(0x8D)\n\n# Subclassing FrameBuffer provides support for graphics primitives\n\n# http:\/\/docs.micropython.org\/en\/latest\/pyboard\/library\/framebuf.html",
                "char_count": 1148,
                "token_estimate": 287
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "How to install or update MicroPython firmware? > Upload dependencies libraries",
                "chunk_index": 23,
                "content": "class SSD1306(framebuf.FrameBuffer):\n        def (self, width, height, external_vcc):\n            self.width = width\n            self.height = height\n            self.external_vcc = external_vcc\n            self.pages = self.height \/\/ 8\n            self.buffer = bytearray(self.pages * self.width)\n            super().(self.buffer, self.width, self.height, framebuf.MONO_VLSB)\n            self.init_display()\n\ndef init_display(self):\n            for cmd in (\n                SET_DISP | 0x00,  # off\n\n# address setting\n\nSET_MEM_ADDR,\n                0x00,  # horizontal\n\n# resolution and layout\n\nSET_DISP_START_LINE | 0x00,\n                SET_SEG_REMAP | 0x01,  # column addr 127 mapped to SEG0\n\nSET_MUX_RATIO,\n                self.height - 1,\n                SET_COM_OUT_DIR | 0x08,  # scan from COM[N] to COM0\n\nSET_DISP_OFFSET,\n                0x00,\n                SET_COM_PIN_CFG,\n                0x02 if self.width > 2 * self.height else 0x12,\n                # timing and driving scheme\n\nSET_DISP_CLK_DIV,\n                0x80,\n                SET_PRECHARGE,\n                0x22 if self.external_vcc else 0xF1,\n                SET_VCOM_DESEL,\n                0x30,  # 0.83*Vcc\n\n# display",
                "char_count": 1194,
                "token_estimate": 299
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "How to install or update MicroPython firmware? > Upload dependencies libraries",
                "chunk_index": 24,
                "content": "SET_CONTRAST,\n                0xFF,  # maximum\n\nSET_ENTIRE_ON,  # output follows RAM contents\n\nSET_NORM_INV,  # not inverted\n\n# charge pump\n\nSET_CHARGE_PUMP,\n                0x10 if self.external_vcc else 0x14,\n                SET_DISP | 0x01,\n            ):  # on\n\nself.write_cmd(cmd)\n            self.fill(0)\n            self.show()\n\ndef poweroff(self):\n            self.write_cmd(SET_DISP | 0x00)\n\ndef poweron(self):\n            self.write_cmd(SET_DISP | 0x01)\n\ndef contrast(self, contrast):\n            self.write_cmd(SET_CONTRAST)\n            self.write_cmd(contrast)\n\ndef invert(self, invert):\n            self.write_cmd(SET_NORM_INV | (invert & 1))\n\ndef show(self):\n            x0 = 0\n            x1 = self.width - 1\n            if self.width == 64:\n                # displays with width of 64 pixels are shifted by 32\n\nx0 += 32\n                x1 += 32\n            self.write_cmd(SET_COL_ADDR)\n            self.write_cmd(x0)\n            self.write_cmd(x1)\n            self.write_cmd(SET_PAGE_ADDR)\n            self.write_cmd(0)\n            self.write_cmd(self.pages - 1)\n            self.write_data(self.buffer)",
                "char_count": 1119,
                "token_estimate": 280
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "How to install or update MicroPython firmware? > Upload dependencies libraries",
                "chunk_index": 25,
                "content": "class SSD1306_I2C(SSD1306):\n        def (self, width, height, i2c, addr=0x3C, external_vcc=False):\n            self.i2c = i2c\n            self.addr = addr\n            self.temp = bytearray(2)\n            self.write_list = [b\"\\x40\", None]  # Co=0, D\/C#=1\n\nsuper().(width, height, external_vcc)\n\ndef write_cmd(self, cmd):\n            self.temp[0] = 0x80  # Co=1, D\/C#=0\n\nself.temp[1] = cmd\n            self.i2c.writeto(self.addr, self.temp)\n\ndef write_data(self, buf):\n            self.write_list[1] = buf\n            self.i2c.writevto(self.addr, self.write_list)\n\nclass SSD1306_SPI(SSD1306):\n        def (self, width, height, spi, dc, res, cs, external_vcc=False):\n            self.rate = 10 * 1024 * 1024\n            dc.init(dc.OUT, value=0)\n            res.init(res.OUT, value=0)\n            cs.init(cs.OUT, value=1)\n            self.spi = spi\n            self.dc = dc\n            self.res = res\n            self.cs = cs\n            import time\n\nself.res(1)\n            time.sleep_ms(1)\n            self.res(0)\n            time.sleep_ms(10)\n            self.res(1)\n            super().(width, height, external_vcc)",
                "char_count": 1115,
                "token_estimate": 279
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "How to install or update MicroPython firmware? > Upload dependencies libraries",
                "chunk_index": 26,
                "content": "def write_cmd(self, cmd):\n            self.spi.init(baudrate=self.rate, polarity=0, phase=0)\n            self.cs(1)\n            self.dc(0)\n            self.cs(0)\n            self.spi.write(bytearray([cmd]))\n            self.cs(1)\n\ndef write_data(self, buf):\n            self.spi.init(baudrate=self.rate, polarity=0, phase=0)\n            self.cs(1)\n            self.dc(1)\n            self.cs(0)\n            self.spi.write(buf)\n            self.cs(1)\n\n-   Download ssd1306.py zipped file: <File:Ssd1306.zip>\n\n<!-- -->\n\nNOTE: Unzip it before upload it to Raspberry Pi Pico",
                "char_count": 569,
                "token_estimate": 143
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "How to install or update MicroPython firmware? > Demo code",
                "chunk_index": 27,
                "content": "-   Create a new file and copy and paste following demo code into it.\n\n<!-- -->\n\nfrom machine import Pin, I2C, ADC\n    from ssd1306 import SSD1306_I2C\n    import framebuf\n    import time\n    import ina3221\n    from math import floor\n\nWIDTH = 128\n    HEIGHT = 32\n\n# logo",
                "char_count": 269,
                "token_estimate": 68
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "How to install or update MicroPython firmware? > Demo code",
                "chunk_index": 28,
                "content": "buffer = bytearray(b'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x1f\\xe3\\xf8?\\xc3\\xc0\\x1f\\xe0?\\xc0\\x03\\xfc\\x03\\xc1\\xfc\\x00?\\xc3\\xfc?\\xf1\\xc0\\x1f\\xf8\\x7f\\x80\\x03\\xff\\x0f\\x81\\xfe\\x00\\x18C\\x1e9\\xf0\\x00\\x1cx\\xf0\\xc0\\x03\\x9f\\x1f\\xc0\\x0f\\x008\\x00\\x0exx\\x00\\x1c<\\xe0\\x00\\x03\\x87\\x9d\\x80\\x0f\\x008\\x00\\x0e8s\\x80\\x1c8\\xf0\\x00\\x03\\x87\\x03\\xc0\\x06\\x00:\\x00\\x1e8y\\xc0\\x1c8x\\x00\\x03\\x87\\x81\\x80\\x0e\\x00?\\xc0\\x1c8s\\x80\\x1dx~\\x00\\x03\\x87\\x03\\xc0\\xfc\\x00?\\xc0<?\\xf1\\xc0\\x1f\\xe0?\\x80\\x03\\xff\\x03\\x80\\xfc\\x00\\x01\\xe0\\xf8?",
                "char_count": 1099,
                "token_estimate": 275
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "How to install or update MicroPython firmware? > Demo code",
                "chunk_index": 29,
                "content": "\\xc3\\x80\\x1f\\xe0\\x0f\\x87\\xc3\\xfc\\x01\\xc0>\\x00\\x00\\xe1\\xe0\\x7f\\x01\\xc0\\x1c\\xf0\\x03\\xcf\\xc7\\xf0\\x03\\x80\\x07\\x00\\x00\\xe3\\xc08\\x03\\x80\\x1cp\\x01\\xc0C\\x80\\x01\\xc0\\x07\\x00\\x00\\xe7\\x808\\x03\\xc0\\x1cx\\x81\\xc0\\x03\\x80\\x03\\x80\\x07\\x00!\\xe7\\xba8\\x01\\x80\\x1c<\\xd7\\xc0\\x03\\x80\\x01\\xc1\\x1f\\x00?\\xc7\\xfe8\\x03\\xc0\\x1c\\x1c\\xff\\x80\\x03\\x80\\x03\\x83\\xfe\\x00?\\x87\\xfex\\x01\\x80\\x1c\\x1e\\x7f\\x00\\x07\\x80\\x03\\xc1\\xfc\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00')\n    fb = framebuf.FrameBuffer(buffer, 128, 32, framebuf.MONO_HLSB)",
                "char_count": 910,
                "token_estimate": 228
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "How to install or update MicroPython firmware? > Demo code",
                "chunk_index": 30,
                "content": "i2c = I2C(0, scl=Pin(5), sda=Pin(4),freq=200000)\n\nprint(i2c.scan())\n\noled = SSD1306_I2C(WIDTH, HEIGHT, i2c, addr=0x3C)\n\nINA3221_ADDR1 = hex(i2c.scan()[1])\n    INA3221_ADDR2 = hex(i2c.scan()[2])\n    print(INA3221_ADDR1)\n    print(INA3221_ADDR2)\n\n# create instance of ina3221 chip.  0x41 and 0x40 are the register address of the chip.\n\nina1 = ina3221.INA3221(i2c, 0x41)\n    ina2 = ina3221.INA3221(i2c, 0x40)\n    # clear screen\n\noled.fill(0)\n\noled.invert(0)\n    oled.fill(0)\n    oled.blit(fb, 0, 0)\n    oled.show()\n    time.sleep(5)\n    oled.fill(0)\n    # Put text on screen\n\n#oled.text(\"Hello World\", 0, 0)\n    while True:\n\nvbus1 = ina2.getVBus(0) \/ 1000.0  # 5v\n\nvbus2 = ina2.getVBus(1) \/ 1000.0  # 5v\n\nvbus3 = ina2.getVBus(2) \/ 1000.0  # total 32v\n\nvbus4 = ina1.getVBus(1) \/ 1000.0 # 12v\n\nch1_current = ina2.getI(chl_num=0)\n        ch2_current = ina2.getI(chl_num=1)\n        ch3_current = ina2.getI(chl_num=2)\n        ch4_current = ina1.getI(chl_num=1)\n\noled.text(f\"CH1:{vbus1:.1f}V\", 0, 0)\n        oled.text(f\" {ch1_current \/1000000.0:.1f}A\", 64,0)\n\noled.text(f\"CH2:{vbus2:.1f}V\", 0, 8)\n        oled.text(f\" {ch2_current \/1000000.0:.1f}A\", 64,8)",
                "char_count": 1146,
                "token_estimate": 287
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "How to install or update MicroPython firmware? > Demo code",
                "chunk_index": 31,
                "content": "oled.text(f\"CH3:{vbus3:.1f}V\", 0, 16)\n        oled.text(f\" {ch3_current\/1000000.0:.1f}A\", 64,16)\n\noled.text(f\"CH4:{vbus4:.1f}V\", 0, 24)\n        oled.text(f\" {ch4_current\/1000000.0:.1f}A\", 64,24)\n        oled.show()\n        time.sleep(3)\n        oled.fill(0)\n        I_shunt0 = ina2.getIShunt(0)\n        I_shunt1 = ina2.getIShunt(1)\n        I_shunt2 = ina2.getIShunt(2)\n        I_shunt3 = ina1.getIShunt(0)\n        I_shunt4 = ina1.getIShunt(1)\n        I_shunt5 = ina1.getIShunt(2)\n        oled.text(f\"V0:{(I_shunt0 \/ 1000000.0):.2f}A\",0, 0)\n        print(I_shunt0)\n        oled.text(f\"I1:{(I_shunt1 \/ 1000000.0):.2f}A\",68, 0)\n        oled.text(f\"I2:{(I_shunt2 \/ 1000000.0):.2f}A\",0, 8)\n        oled.text(f\"I3:{(I_shunt3 \/ 1000000.0):.2f}A\",68, 8)\n        oled.text(f\"I4:{(I_shunt4 \/ 1000000.0):.2f}A\",0, 16)\n        oled.text(f\"I5:{(I_shunt5 \/ 1000000.0):.2f}A\",68, 16)\n        oled.show()\n        time.sleep(3)\n        oled.fill(0)\n\nSave it as \"main.py\" to Raspberry Pi Pico or test it by click play button on thonny menu. It will measure the voltage and current on each USB port, you can change the democode to fit for your own request.",
                "char_count": 1137,
                "token_estimate": 285
            },
            {
                "title": "EP-0249",
                "rev_id": 15732,
                "heading_path": "YouTuBe Tutorial",
                "chunk_index": 32,
                "content": "-   YoutuBe Tutorial URL: <https:\/\/youtu.be\/uHrA0ky3zVA>",
                "char_count": 56,
                "token_estimate": 14
            }
        ]
    }
}