EP-0250
UPS Gen 6 power module compatible with Raspberry Pi 5/4B
Description
UPS Gen 6 power module compatible with Raspberry Pi 5/4B (UPSv6 for short) is the latest evolution of our UPS Plus series, designed to provide enhanced power management and flexibility for Raspberry Pi or other SBCs. Built on the foundation of its predecessor, UPS v6 introduces significant improvements in battery configuration, power path management, and user customization options. The UPS v6 supports up to 4 channels of 8.4V lithium battery groups connected in, parallel allowing users to expand battery capacity for extended runtime. It can be expanded by using more battery slot with two 3.7V 18650 lithium batteries connected in series, offering versatile power solutions. The device features intelligent power path management, prioritizing external power when available and seamlessly switching to battery power during outages. Equipped with I2C communication, UPS v6 enables real-time monitoring of battery voltage, temperature, capacity, and device version information. Users can leverage DFU upgrade support to upload custom firmware, ensuring maximum flexibility and control. For DIY enthusiasts, UPS v6 offers programmable LED indicators and a PikaPython interface, allowing users to upload Python scripts for advanced device status monitoring and control. Additional features include auto-restart on power recovery with configurable voltage thresholds, safe shutdown countdown, and protection against low-battery loops. Whether you need reliable backup power, customizable monitoring, or advanced power management, UPS v6 delivers a powerful and versatile solution for your Raspberry Pi or Orange Pi projects, and It can get more feature during OTA firmware upgrade in future.
Key Features
- Bumpless Transfer
- Hard Disk Power Supply Interface
- Cooling System
- OTA Expansion for Additional Functions
- I2C Communication Interface
- PikaPython Script Execution Capability
- Physical Power Button
Specifications
- Device Compatibility: Supports Raspberry Pi and Orange Pi series devices.
- Expansion Battery Pack Support:Supports 18650 battery packs with two batteries in series, providing a typical voltage of 7.4V and a maximum voltage of 8.4V, with up to four parallel battery packs supported.
- Power Management: Bumpless Transfer, Full UPS (Uninterruptible Power Supply) characteristics, supporting seamless failover to battery power.
- Communication Interface: I2C protocol for battery and device status monitoring and controlling.
- DIY Features: Programmable LED control via configuring i2c registers.
- PikaPython support:PikaPython script interpreter for Python script injection.
- Power Recovery Settings: Configurable voltage thresholds for auto-restart.
- Safe shutdown timer to prevent data loss.
- Get more feature via OTA upgrade.
Compatibility Note
The screws, copper pillars, and other additional components of this product are primarily designed to fit the Raspberry Pi 5 and Raspberry Pi 4B. However, the product's functionality is compatible with other SBC (Single Board Computer) development boards on the market that are pin-compatible with the Raspberry Pi. If you need to install it smoothly, you may need to check whether the positioning hole locations match those of the Raspberry Pi 5 or Raspberry Pi 4B. Otherwise, it may not be physically compatible. This is hereby declared.
UPS features Details
Feature 1: Auto Start Mode
- Register: auto_start_mode
- Function: Enables automatic power-on logic when written.
- Conditions for Auto Start: when Battery voltage > auto_start_voltage and Valid external power source present
- Protection Mechanism: Monitors battery voltage after auto-start; If voltage drops to battery_protection_voltage multiple times:
Auto-start attempts will be abandoned
- Manual Shutdown by Button
Auto clears auto_start_mode functionality
Feature 2: Delayed Shutdown
- Register: shutdown_countdown
Initiates shutdown after specified seconds when written.
- Important Notes
Combined with active auto_start_mode: Functions as a reboot if conditions are met For complete shutdown: Must clear auto_start_mode setting
Feature 3: Runtime Tracking
- Register: runtime
- Unit: milliseconds (ms)
- Functionality: Tracks continuous operation time since last power-on
Feature 4: Force OTA Mode
- Register: ota_request
- Write value: 0xA5A5
- Behavior: Immediately forces device into OTA mode
Feature 5: Physical Button Control
- Current Implementation
Single button operation Toggles power state immediately
Important Notice
- Immediate shutdown risks: Potential data loss
- Recommended method: Use shutdown_countdown for safe shutdown
Feature 6: L_FAST LED Indicators
LED State | Meaning |
---|---|
Fast blinking | Bootloader mode |
Solid on | Fast charging available |
Slow blinking | UPS Fault |
Off | No input power |
Gallery
TBD.
Package List
TBD.
How to assemble it?
TBD.
User Manual
- Please read the user manual carefully before proceeding.
This documentation assumes you are using a Raspberry Pi for testing. You can also use Orange Pi devices, but you will need to adjust the I2C controller address based on your specific setup. The default I2C device address for Raspberry Pi is /dev/i2c-1, while Orange Pi may use /dev/i2c-3. Adjust these settings according to your hardware.
The testing environment for this documentation includes:
- Raspberry Pi 5
- 4 battery groups, each consisting of two fully charged 18650 lithium batteries connected in series to provide 8.4V.
- A 100W USB-C PD protocol charger.
- Raspberry Pi OS 64-bit Bookworm, updated to the latest version.
If you are using a different operating system, refer to its specific environment configuration. Note that we currently provide configuration guidance only for Raspberry Pi OS. For other systems, please resolve compatibility issues independently.
Register Summary Table
Address | Name | Width | Access | Description | Default Value |
---|---|---|---|---|---|
0x00 | WHO_AM_I | 8 | R | Device identification register | 0xA6 |
0x01 | version | 8 | R | Version number | - |
0x02 | uuid0 | 32 | R | Unique ID (lower 32 bits) | - |
0x06 | uuid1 | 32 | R | Unique ID (middle 32 bits) | - |
0x0A | uuid2 | 32 | R | Unique ID (upper 32 bits) | - |
0x0E | output_voltage | 16 | R | Output voltage (unit: mV, 5V output) | - |
0x10 | input_voltage | 16 | R | Input voltage (unit: mV) | - |
0x12 | battery_voltage | 16 | R | Battery voltage (unit: mV) | - |
0x14 | mcu_voltage | 16 | R | MCU voltage (unit: mV) | - |
0x16 | output_current | 16 | R | Output current (unit: mA, 5V output) | - |
0x18 | input_current | 16 | R | Input current (unit: mA) | - |
0x1A | battery_current | 16 | R | Battery current (signed, unit: mA) | - |
0x1C | temperature | 8 | R | Temperature (two's complement, unit: °C) | - |
0x1D | CR1 | 8 | R/W | Control Register 1 | 0x01 |
0x1E | CR2 | 8 | R/W | Control Register 2 (Reserved) | 0x00 |
0x1F | SR1 | 8 | R | Status Register 1 | - |
0x20 | SR2 | 8 | R | Status Register 2 | - |
0x21 | battery_protection_voltage | 16 | R/W | Battery protection voltage (unit: mV) | 7400 |
0x23 | shutdown_countdown | 16 | R/W | Shutdown countdown (unit: seconds) | - |
0x25 | auto_start_voltage | 16 | R/W | Auto-start voltage threshold (unit: mV) | 7400 |
0x27 | rsv | 16 | R/W | Python output buffer content length | - |
0x29 | ota_request | 16 | W | Writing to 0xA5A5 will request OTA mode. | - |
0x2B | runtime | 64 | R | Cumulative runtime (unit: microseconds) | - |
0x33 | charge_detect_interval_s | 16 | R/W | Charge detection interval (unit: seconds) | - |
0x35 | led_ctl | 8 | R/W | LED control register | 0x01 |
Control Register CR1 (Address: 0x1D)
Bit | Name | Access | Description | Default Value |
---|---|---|---|---|
BIT0 | auto_start_mode | R/W | Auto-start mode (0=disabled, 1=enabled) | 1 |
Status Register SR1 (Address: 0x1F)
Bit | Name | Access | Description | Default Value |
---|---|---|---|---|
BIT0 | sw_status | R | 5V output status (0=off, 1=on) | - |
BIT1 | fast | R | Fast charging status (0=slow charging/no external power, 1=12V fast charging) | - |
BIT2 | charge | R | Charge/discharge status (0=charging, 1=discharging) | - |
BIT3 | input_low | R | Input voltage low (0=normal, 1=low) | - |
BIT4 | output_low | R | 5V output low (0=normal, 1=low) | - |
BIT5 | battery_low | R | Battery voltage low (0=normal, 1=low) | - |
BIT6 | adc_mismatch | R | ADC mismatch (0=normal, 1=INA219 vs MCU sampling difference exceeded) | - |
BIT7 | battery_fail | R | Battery failure (0=normal, 1=failure) | - |
Status Register SR2 (Address: 0x20)
Bit | Name | Access | Description | Default Value |
---|---|---|---|---|
BIT0 | i2c_ack | R/W | LED on during I2C communication | 1 |
BIT1 | bat_charge | R/W | LED on during battery charging | 0 |
BIT2 | bat_discharge | R/W | LED on during battery discharging | 0 |
BIT3 | fault_report | R/W | LED on when fault detected | 0 |
BIT4 | ok_report | R/W | LED on during normal operation | 0 |
LED Control Register (Address: 0x35)
Bit | Name | Access | Description | Default Value |
---|---|---|---|---|
BIT0 | i2c_ack | R/W | LED on during I2C communication | 1 |
BIT1 | bat_charge | R/W | LED on during battery charging | 0 |
BIT2 | bat_discharge | R/W | LED on during battery discharging | 0 |
BIT3 | fault_report | R/W | LED on when fault detected | 0 |
BIT4 | ok_report | R/W | LED on during normal operation | 0 |
Special Notes
- Data Format:
Voltage/current values are unsigned integers battery_current is signed (two's complement format) temperature is signed 8-bit integer (two's complement), range: -40°C to +85°C
- Reserved Bits:
All reserved bits default to 0 Write operations to reserved bits are ignored (recommended to maintain default values)
- The register definitions in the bootloader state are not fully compatible.
Getting Start
- Assume that your Device Environment: Raspberry Pi 5, operating system: Raspberry Pi OS 64-bit (Bookworm).
- Assume that your Raspberry Pi 5 can access internet including GitHub.
- Assume that you have already assembled the UPS v6 with your Raspberry Pi 5 and booting up properly.
- Please refer to the following steps for operation:
Install Dependencies package and libraries
- Open a terminal and typing:
sudo apt update sudo apt upgrade -y sudo apt -y install build-essential cmake libi2c-dev libssl-dev gcc-arm-none-eabi git wget vim-* virtualenv i2c-tools
Download Demo codes repository
- In order to use this module easily, I recommend you download the repository from GitHub, URL: [ https://github.com/geeekpi/upsv6_pub.git ]
- Download to Raspberry Pi 5 locally, you need to open a terminal and typing following commands:
cd ~/ git clone https://github.com/geeekpi/upsv6_pub.git
or just open a browser and access this URL: [ https://github.com/geeekpi/upsv6_pub.git ], click `code` -> click `Download ZIP` and then extract the contents to your Raspberry Pi 5 on desktop.
Upload new firmware
- Step 1. Enter into OTA mode
- Step 2. Upload new firmware_encrypted.bin file
python enable_ota.py
Check if the UPS v6 has been entered into OTA mode:
i2cdetect -y 1
If the i2c device address is changed from 0x17 to 0x18 means UPSv6 is already in OTA mode.
./user_write_tool firmware_encrypted.bin
Until you see following figure:
Push button status
- Push button will keep the status after last operation.