PiSugar Documentation

website·Indexed 32 days ago

https://docs.pisugar.com

Technical documentation for PiSugar battery and UPS solutions for Raspberry Pi, including the PiSugar 1, 2, 3, and S series. Covers hardware specifications, I2C communication, the PiSugar Power Manager software, RTC configuration, and the Whisplay multifunctional expansion HAT.

Tokens
16.1K
Snippets
76
Records
133
Agent score
58%

What's inside PiSugar

  1. Overview of PiSugar Whisplay HAT hardware capabilities

    The PiSugar Whisplay HAT is an expansion board for the Raspberry Pi Zero designed to integrate multimedia interfaces into a single compact form factor. It includes the following hardware components:

    • Display: 1.69-inch IPS LCD (240x280 pixels)
    • Audio Input: Dual microphones for voice recognition and recording
    • Audio Output: Built-in speaker for playback and notifications
    • Input: Mouse buttons for navigation and control
    • Feedback: RGB LED indicator for status and visual alerts
  2. PiSugar S and S Plus Hardware Overview

    The PiSugar S and S Plus provide power solutions for Raspberry Pi. Note that these models do not support data communication; battery status cannot be retrieved. For battery status monitoring, use the PiSugar 2 or 3 series instead.
  3. Install PiSugar WiFi Config via one-liner

    Install the PiSugar WiFi Config BLE service as a systemd service using a pre-built binary. The installation script automatically detects the Raspberry Pi architecture (ARMv6, ARMv7, or AArch64) and downloads the appropriate binary.
    # Install latest version
    curl -sSL https://repo.pisugar.uk/PiSugar/sugar-wifi-conf/raw/master/install-bin.sh | sudo bash
    
    # Install a specific version (e.g., v0.1.0)
    curl -sSL https://repo.pisugar.uk/PiSugar/sugar-wifi-conf/raw/master/install-bin.sh | sudo bash -s -- v0.1.0
  4. PiSugar3 Air Hardware Overview

    The PiSugar3 Air is a lightweight variant of the PiSugar 3. It provides power management, RTC, I2C, UPS, and Type-C charging, but replaces the built-in battery with a pluggable connector for user-selected batteries.

    Key Hardware Specs:

    • PowerIC: Standalone MCU
    • RTC: DS3231 (stimulated by MCU)
    • Charging: Type-C port with E-mark support
    • Interface: I2C interface, 5V output
    • Controls: Tap Power Button and Programmable Tap Button
    • PCB Size: 65mm x 30mm
  5. Charge and Wake Up PiSugar2 Plus

    Charging: Use the dedicated Type-C or Micro USB ports on the PiSugar2 Plus. Charging via the Raspberry Pi's own USB port will not charge the PiSugar battery and will cause the PiSugar to turn off automatically as it detects external power.

    Scheduled Wake Up: To use the schedule wake-up function, keep the physical power switch ON. The battery will power down when the Pi shuts down, and the RTC will trigger the battery and Pi to wake up at the scheduled time.

  6. Detect charging status on PiSugar2Pro (IP5312)

    Charging status is detected using the ADC pin (Vset function pin). An overflow is measured when charging, while a random value is returned when not charging.

    Critical Requirement: You must disable register 0x54 before changing register 0x55, otherwise the change will be ignored.

    Step 1: Set register 0x29 (BATSET_sel = 0) to use internal register
    Step 2: Set register 0x52 (VSET_sel = 10) to ADC function
    Step 3: Set register 0xC2 (VGPI) to 0 (Enable) or 1 (Disable)
  7. Power on and off the PiSugar 3

    By default, the Anti-mistaken Touch feature is enabled.

    • Power-On: Short press, then long press (Click & Hold). The device is on when the LEDs count from 1 to 4.
    • Power-Off: Long press the power button.

    The Anti-mistaken Touch switch can be toggled in the webUI under Advanced Settings -> Anti-Mistaken Touch Switch.

  8. Control battery charging on PiSugar2Pro (IP5312)

    Charging can be enabled or disabled using the GPIO2 pin.

    Critical Requirement: You must disable register 0x54 before changing register 0x55, otherwise the change will be ignored.

    Step 1: Set register 0x52 to GPIO2 (LIGHT_sel = 1)
    Step 2: Set GPIO2 in register 0x56 to disabled
    Step 3: Set register 0x58 to 0 (Enable Charging) or 1 (Disable Charging)
    Step 4: Set GPIO2 in register 0x54 to enabled
  9. Downclock I2C-7 to 100kHz for PiSugar3 on Radxa Cubie A7Z

    On the Radxa Cubie A7Z, the default I2C frequency for i2c-7 is 400kHz, which may cause instability or failure in detecting the PiSugar3 battery device (address 0x57). To improve detection success, the I2C frequency can be downclocked to 100kHz by modifying the TWI7 overlay. This process involves decompiling the .dtbo file, updating the clock-frequency value, and recompiling it.
    # Backup, decompile, modify frequency from 400kHz (0x61a80) to 100kHz (0x186a0), recompile and reboot
    printf 'radxa\n' | sudo -S sh -c '
    cp -a /boot/dtbo/sun60iw2p1-twi7.dtbo /boot/dtbo/sun60iw2p1-twi7.dtbo.bak-400k
    dtc -I dtb -O dts -o /tmp/sun60iw2p1-twi7.dts /boot/dtbo/sun60iw2p1-twi7.dtbo
    sed -i "s/clock-frequency = <0x61a80>/clock-frequency = <0x186a0>/" /tmp/sun60iw2p1-twi7.dts
    dtc -@ -I dts -O dtb -o /boot/dtbo/sun60iw2p1-twi7.dtbo /tmp/sun60iw2p1-twi7.dts
    reboot
    '