{
    "ok": true,
    "data": {
        "title": "EP-0256",
        "rev_id": 16343,
        "updated_at": "2026-04-29T05:26:17+00:00",
        "chunk_count": 17,
        "chunks": [
            {
                "title": "EP-0256",
                "rev_id": 16343,
                "heading_path": "",
                "chunk_index": 0,
                "content": "# EP-0256\n\n**Product SKU**: EP-0256",
                "char_count": 35,
                "token_estimate": 9
            },
            {
                "title": "EP-0256",
                "rev_id": 16343,
                "heading_path": "Description",
                "chunk_index": 1,
                "content": "The SBS (Smart Battery System) Module is an advanced battery management solution designed specifically for the UPS Gen 6 platform. This module implements the industry-standard SBS communication protocol to provide intelligent monitoring and control of lithium battery packs. By integrating precision analog front-end circuitry with a compliant SBS firmware stack, it delivers real-time battery telemetry including voltage, current, state of charge, and runtime estimation. The module supports I2C communication interfaces compatible with both PikaPython embedded environments and native Raspberry Pi I2C buses, making it versatile for various development scenarios. With open-source firmware architecture, users benefit from transparent battery management algorithms while maintaining flexibility for customization. The module ensures safe and efficient battery operation through balanced charging capabilities and configurable I2C addressing, making it an ideal power management companion for UPS Gen 6 battery expansion boards.",
                "char_count": 1029,
                "token_estimate": 258
            },
            {
                "title": "EP-0256",
                "rev_id": 16343,
                "heading_path": "Features",
                "chunk_index": 2,
                "content": "-   <strong>Balanced Charging Protection:<\/strong> Lithium battery charging incorporates cell balancing functionality to prevent battery damage and extend pack longevity\n-   <strong>SBS Protocol Compliance:<\/strong> Device firmware adheres to Smart Battery System (SBS) communication standards for interoperability\n-   <strong>UPS Gen 6 Compatibility: <\/strong>Fully compatible with UPS Gen 6 battery expansion boards for seamless integration\n-   <strong>Flexible I2C Communication:<\/strong> Supports I2C protocol communication compatible with both PikaPython environments and native Raspberry Pi I2C interfaces for reading battery voltage, current, and status parameters\n-   <strong>Open-Source Firmware:<\/strong> SBS firmware is open-source, enabling transparency and customization\n-   <strong>Enhanced Battery Management:<\/strong> Provides safer and more convenient battery management capabilities\n-   <strong>Configurable I2C Address:<\/strong> I2C communication address selectable via jumper configuration\n-   <strong>High-Precision Acquisition:<\/strong> Utilizes high-precision operational amplifiers for voltage and current sensing, delivering accurate readings",
                "char_count": 1167,
                "token_estimate": 292
            },
            {
                "title": "EP-0256",
                "rev_id": 16343,
                "heading_path": "Features",
                "chunk_index": 3,
                "content": "-   <strong>Intelligent Runtime Estimation: <\/strong>Smart algorithms estimate remaining battery runtime, providing battery percentage and charge\/discharge state indication",
                "char_count": 172,
                "token_estimate": 43
            },
            {
                "title": "EP-0256",
                "rev_id": 16343,
                "heading_path": "Gallery",
                "chunk_index": 4,
                "content": "TBD.",
                "char_count": 4,
                "token_estimate": 1
            },
            {
                "title": "EP-0256",
                "rev_id": 16343,
                "heading_path": "How to assemble it?",
                "chunk_index": 5,
                "content": "TBD.",
                "char_count": 4,
                "token_estimate": 1
            },
            {
                "title": "EP-0256",
                "rev_id": 16343,
                "heading_path": "How to setup? > Auto Setup",
                "chunk_index": 6,
                "content": "-   Download setup shell script from GitHub: \\[ <https:\/\/github.com\/geeekpi\/sbs_battery_for_UPS_Gen6> \\]\n-   Execute the setup.sh shell script.",
                "char_count": 143,
                "token_estimate": 36
            },
            {
                "title": "EP-0256",
                "rev_id": 16343,
                "heading_path": "How to setup? > Quick Start",
                "chunk_index": 7,
                "content": "-   Download the script\n\n<!-- -->\n\n    curl -O https:\/\/example.com\/install_sbs_battery.sh\n    chmod +x install_sbs_battery.sh\n\n-   Run full installation\n\n<!-- -->\n\n    sudo .\/install_sbs_battery.sh\n\n-   Reboot to activate\n\n<!-- -->\n\n    sudo reboot\n\n-   After reboot, check battery status\n\n<!-- -->\n\n    batt\n\n-   More information please visit: \\[ <https:\/\/github.com\/geeekpi\/sbs_battery_for_UPS_Gen6> \\]",
                "char_count": 404,
                "token_estimate": 101
            },
            {
                "title": "EP-0256",
                "rev_id": 16343,
                "heading_path": "How to setup? > Hand-crafting step by step",
                "chunk_index": 8,
                "content": "Raspberry Pi SBS Battery Module Compilation Guide\n\n#### Overview\n\nThis guide explains how to compile the SBS (Smart Battery System) battery driver as an external kernel module on Raspberry Pi 5, create a Device Tree overlay to instantiate the device, and configure automatic loading at boot time — all without recompiling the entire kernel.\n\n##### Prerequisites\n\n-   Raspberry Pi 5 (or compatible model, Raspberry Pi 4B etc.)\n-   Running Raspberry Pi OS with kernel headers installed\n-   I2C interface enabled\n-   SBS-compatible battery connected via I2C (default address: 0x0a)\n\n------------------------------------------------------------------------\n\nPart A: Compile External Kernel Module (Out-of-Tree)\n<strong>Step A0: Install Required Kernel Headers<\/strong>\nYou must install kernel headers that exactly match your running kernel:\n\nsudo apt update\n    sudo apt upgrade -y\n    sudo apt install -y \"linux-headers-$(uname -r)\"\n\nImportant: The build directory musb be \"\/lib\/modules\/$(uname -r)\/build\n\nVerify the kernel build directory:\n\nKDIR=\/lib\/modules\/$(uname -r)\/build\n    readlink -f \"$KDIR\"\n    ls -l \"$KDIR\"",
                "char_count": 1116,
                "token_estimate": 279
            },
            {
                "title": "EP-0256",
                "rev_id": 16343,
                "heading_path": "How to setup? > Hand-crafting step by step",
                "chunk_index": 9,
                "content": "<strong>Step A1: Obtain Kernel Source Code <\/strong>\nClone the Raspberry Pi Linux repository to extract the sbs-battery.c source file:\n\ngit clone --depth=1 -b rpi-6.12.y https:\/\/github.com\/raspberrypi\/linux ~\/linux\n\nNOTE:This step is only to obtain the sbs-battery.c source file. The actual compilation uses the headers' build tree, so minor version differences between the source tree and your running kernel are generally acceptable. However, API changes may cause compilation failures.\n<strong>Step A2: Create External Module Directory and Makefile<\/strong>\nCreate a working directory for the external module:\n\nmkdir -p ~\/kmods\/sbs\n    cd ~\/kmods\/sbs\n\n# Copy the source file from cloned repository\n\ncp ~\/linux\/drivers\/power\/supply\/sbs-battery.c .\n\n# Create the Makefile\n\ncat > Makefile << 'EOF'\n    obj-m += sbs-battery.o\n    EOF\n\n<strong>Step A3: Compile Using Kernel Headers<\/strong>\nCompile the module using the kernel headers' build directory:\n\nKDIR=\/lib\/modules\/$(uname -r)\/build\n\n# Clean previous builds\n\nmake -C \"$KDIR\" M=\"$PWD\" clean\n\n# Compile the module\n\nmake -C \"$KDIR\" M=\"$PWD\" modules\n\nExpected output files:\n\\* sbs-battery.ko — The loadable kernel module",
                "char_count": 1171,
                "token_estimate": 293
            },
            {
                "title": "EP-0256",
                "rev_id": 16343,
                "heading_path": "How to setup? > Hand-crafting step by step",
                "chunk_index": 10,
                "content": "-   Module.symvers — Module symbol versions\n-   modules.order — Module load order\n\n<strong>Step A4: Manual Loading Verification<\/strong>\nTest the compiled module by manually loading it:\n\nsudo insmod sbs-battery.ko\n\n# Verify module is loaded\n\nlsmod | grep sbs\n\n##### Part B: Create Device Tree Overlay\n\n<strong>Step B0: Identify I2C Controller Device Tree Path<\/strong>\nBefore creating the overlay, you must identify the correct Device Tree path for your I2C controller. For Raspberry Pi 5, the path is:\n\n\/axi\/pcie@1000120000\/rp1\/i2c@74000\n\nTo find the DT path for your specific setup:\n\nOF=$(readlink -f \/sys\/class\/i2c-dev\/i2c-1\/device\/of_node)\n    echo \"DT_PATH=${OF#\/sys\/firmware\/devicetree\/base}\"",
                "char_count": 698,
                "token_estimate": 175
            },
            {
                "title": "EP-0256",
                "rev_id": 16343,
                "heading_path": "How to setup? > Hand-crafting step by step",
                "chunk_index": 11,
                "content": "<img src=\"Output_sbs.png\" title=\"Output_sbs.png\" width=\"800\" alt=\"Output_sbs.png\" \/>\nNOTE: for other Pi models, you will need to determine the appropriate path individually.\n<strong>Step B1: Overlay File Requirements<\/strong>\n{\\| class=\"wikitable\" \\|- ! Requirement!!Specification \\|- \\|Filename suffix \\|\\|Must end with -overlay.dts \\|- \\|Source directive \\|\\| Must include \/plugin\/; \\|- \\|DTC flag\\|\\| Must use @ flag during compilation \\|- \\|Output \\|\\| .dtbo file placed in \/boot\/firmware\/overlays\/ \\|}\n\n<strong> Step B2: Create Overlay Content <\/strong>\nCreate the Device Tree overlay file sbs-battery-overlay.dts:\n\n\/dts-v1\/;\n    \/plugin\/;\n\n\/ {\n        compatible = \"brcm,bcm2712\";\n\nfragment@0 {\n            target-path = \"\/axi\/pcie@1000120000\/rp1\/i2c@74000\";\n\n{\n                status = \"okay\";\n                #address-cells = <1>;\n                #size-cells = <0>;\n\nsbs-battery@a {\n                    compatible = \"sbs,sbs-battery\";\n                    reg = <0x0a>;           \/* I2C addrss default is 0x0A *\/\n                    status = \"okay\";\n                };\n            };\n        };\n    };",
                "char_count": 1108,
                "token_estimate": 277
            },
            {
                "title": "EP-0256",
                "rev_id": 16343,
                "heading_path": "How to setup? > Hand-crafting step by step",
                "chunk_index": 12,
                "content": "Address notation explanation:\n\\* battery@a — Node name (hexadecimal without prefix, following DT convention)\n\n-   reg = \\<0x0a\\> — Actual I2C device address (0x0a = 11 in decimal)\n\nIt is recommended to keep the node name consistent with the reg value for clarity.\n<strong>Step B3: Compile and Install Overlay<\/strong>\nCompile the Device Tree overlay:\n\ndtc -@ -I dts -O dtb -o sbs-battery.dtbo sbs-battery-overlay.dts\n\nInstall the compiled overlay to the system overlays directory:\n\nsudo install -D -m 0644 sbs-battery.dtbo \/boot\/firmware\/overlays\/\n\n<strong>Step B4: Enable the Overlay <\/strong>\nEdit the Raspberry Pi configuration file to enable the overlay:\n\nsudo nano \/boot\/firmware\/config.txt\n\nAdd the following line in the \\[all\\] section (or appropriate section):\n\n[all]\n    dtoverlay=sbs-battery\n\n##### Part C: Configure Automatic Module Loading\n\n<strong>Step C1: Install Module to Standard Path<\/strong>\nInstall the compiled module to the standard kernel modules directory and update dependencies:\n\n# Install module to extra directory\n\nsudo install -D -m 0644 ~\/kmods\/sbs\/sbs-battery.ko \\\n        \/lib\/modules\/$(uname -r)\/extra\/sbs-battery.ko\n\n# Update module dependencies\n\nsudo depmod -a",
                "char_count": 1195,
                "token_estimate": 299
            },
            {
                "title": "EP-0256",
                "rev_id": 16343,
                "heading_path": "How to setup? > Hand-crafting step by step",
                "chunk_index": 13,
                "content": "Recommendation: If you previously loaded the module manually with insmod, remove it first to ensure clean verification of automatic loading:\n\nsudo rmmod sbs-battery\n\n<strong>Step C2: Reboot and Verify<\/strong>\nReboot the system to test automatic loading:\n\nsudo reboot\n\nAfter reboot, verify the module loaded automatically:\n\n# Check if module is loaded\n\nlsmod | grep sbs\n\n# Check kernel messages for SBS\/battery related logs\n\ndmesg | grep -i -E 'sbs|battery|power_supply'\n\n# Check power supply class devices\n\nls \/sys\/class\/power_supply\/\n\n# Verify I2C device detection (should show 1-000a for I2C bus 1, address 0x0a)\n\nls \/sys\/bus\/i2c\/devices | grep '1-000a'\n\nOUTPUT:\n<img src=\"Sbs_grep.png\" title=\"Sbs_grep.png\" width=\"800\" alt=\"Sbs_grep.png\" \/>\n<img src=\"Ls_sbs_status.png\" title=\"Ls_sbs_status.png\" width=\"800\" alt=\"Ls_sbs_status.png\" \/>\n\n##### upower Command Reference\n\n-   upower -e — Enumerate Power Devices\n-   Purpose: Lists all power device paths recognized by the UPower daemon.\n\n<!-- -->\n\nupower -e",
                "char_count": 1007,
                "token_estimate": 252
            },
            {
                "title": "EP-0256",
                "rev_id": 16343,
                "heading_path": "How to setup? > Hand-crafting step by step",
                "chunk_index": 14,
                "content": "Typical Output:\n<img src=\"Upower-e_output.png\" title=\"Upower-e_output.png\" width=\"800\" alt=\"Upower-e_output.png\" \/>\nPerfect! SBS battery is detected at I2C address 0x0a (shown as sbs_1\\_000a). Let me verify the full status and update the scripts for your specific device path:\n\\* Verify Your Battery\n\n-   Usage: upower -i <device> — Inspect Device Information\n\n<!-- -->\n\nupower -i \/org\/freedesktop\/UPower\/devices\/battery_sbs_1_000a\n\n<img src=\"Upower-i_output.png\" title=\"Upower-i_output.png\" width=\"800\" alt=\"Upower-i_output.png\" \/>\n=====Quick Status Scripts===== Essential Info Only (Panel\/Conky Friendly)\n\nupower -i $(upower -e | grep battery) | grep -E \"state|percentage|time to|energy-rate|temperature\"\n\nOutput:\n<img src=\"Quick_check_battery.png\" title=\"Quick_check_battery.png\" width=\"800\" alt=\"Quick_check_battery.png\" \/>\nor you can write a shell script to inspect battery's information:\n\ncat > ~\/.local\/bin\/batt << 'EOF'\n    #!\/bin\/bash\n    DEVICE=\"\/org\/freedesktop\/UPower\/devices\/battery_sbs_1_000a\"\n\n# Colors\n\nGREEN='\\033[0;32m'\n    YELLOW='\\033[1;33m'\n    RED='\\033[0;31m'\n    NC='\\033[0m'\n\n# Get data",
                "char_count": 1111,
                "token_estimate": 278
            },
            {
                "title": "EP-0256",
                "rev_id": 16343,
                "heading_path": "How to setup? > Hand-crafting step by step",
                "chunk_index": 15,
                "content": "RAW=$(upower -i \"$DEVICE\")\n    STATE=$(echo \"$RAW\" | grep \"state:\" | awk '{print $2}')\n    PERCENT=$(echo \"$RAW\" | grep \"percentage:\" | awk '{print $2}' | tr -d '%')\n    VOLTAGE=$(echo \"$RAW\" | grep \"voltage:\" | awk '{print $2}')\n    TEMP=$(echo \"$RAW\" | grep \"temperature:\" | awk '{print $2 \" \" $3}')\n    POWER=$(echo \"$RAW\" | grep \"energy-rate:\" | awk '{print $2 \" \" $3}')\n    ENERGY=$(echo \"$RAW\" | grep \"energy:\" | awk '{print $2 \" \" $3}')\n\n# State color\n\ncase \"$STATE\" in\n        charging) COLOR=$GREEN; ICON=\"🔌\" ;;\n        discharging) COLOR=$YELLOW; ICON=\"🔋\" ;;\n        fully-charged) COLOR=$GREEN; ICON=\"⚡\" ;;\n        *) COLOR=$NC; ICON=\"❓\" ;;\n    esac\n\n# Output\n\necho -e \"${COLOR}${ICON} 52Pi UPSPack-2S${NC}\"\n    echo \"━━━━━━━━━━━━━━━━━━━━━━━\"\n    echo -e \"State:       ${COLOR}${STATE}${NC}\"\n    echo \"Level:       ${PERCENT}%\"\n    echo \"Voltage:     ${VOLTAGE}V\"\n    echo \"Power:       ${POWER}\"\n    echo \"Energy:      ${ENERGY}\"\n    echo \"Temp:        ${TEMP}\"\n    echo \"\"\n    echo \"Device:      sbs-1-000a (I2C 0x0a)\"\n    EOF\n\nchmod +x ~\/.local\/bin\/batt\n\nUsage:\n\nbatt",
                "char_count": 1081,
                "token_estimate": 271
            },
            {
                "title": "EP-0256",
                "rev_id": 16343,
                "heading_path": "How to setup? > Hand-crafting step by step",
                "chunk_index": 16,
                "content": "output:\n<img src=\"Batt_output.png\" title=\"Batt_output.png\" width=\"800\" alt=\"Batt_output.png\" \/>\n\\* Mini Monitor (Auto-Refresh)\n\n# Watch live (updates every 2 seconds)\n\nwatch -n 2 'upower -i \/org\/freedesktop\/UPower\/devices\/battery_sbs_1_000a | grep -E \"state|percentage|voltage|temp|energy-rate\"'\n\n<img src=\"Miniwatch.png\" title=\"Miniwatch.png\" width=\"800\" alt=\"Miniwatch.png\" \/>",
                "char_count": 378,
                "token_estimate": 95
            }
        ]
    }
}