PiPower - Raspberry Pi UPS with Battery

Thanks for choosing our PiPower.

Note

This document is available in the following languages.

Please click on the respective links to access the document in your preferred language.

_images/media1.png

What a UPS Does?

If your Raspberry Pi project requires constant power, relying only on the main power system is not a viable option. Depending on your location, power drops and surges may occur frequently and often last for hours. Any power fluctuations can damage your Raspberry Pi, and a power outage will immediately shut it down. Consequently, it will not shut down safely, which can result in all data on the SD card being lost, increasing the chances of it being destroyed.

Therefore, the use of an uninterruptible power supply (UPS) is recommended.

With a UPS, if there is a power interruption from the mains (interruption = power outage), the battery or other power source will take over and continue to power the device without shutting it down. A UPS is often considered an emergency power source. After the main power source is repaired, the UPS will recharge and be ready to handle the next disaster.

About PiPower

That’s why we designed PiPower in the first place. PiPower can be used as a second power source for the Raspberry Pi. A USB-C mains power supply plugged into the PiPower will directly power the Raspberry Pi and charge the battery at low current. PiPower can seamlessly power up a Raspberry Pi in the event of a power outage or disconnection of USB-C mains power.

PiPower can output 5V/3A power supply to meet various Raspberry Pi usage situation. It has 4 power indicators; each indicator represents 25% of the power, and is equipped with a power switch to turn on/off the power of the Raspberry Pi without plugging or unplugging the power cord.

Warning

When you put the battery in for the first time or when the battery is unplugged and put in again, the battery will not work properly, at this time, you need to plug the Type C cable into the charging port to turn off the protection circuit, and the battery can be used normally.

About the display language

This document is available in other languages as well. To switch the display language, kindly click on the Read the Docs icon located in the lower left corner of the page.

_images/translation.png

Component List

_images/media3.png

Assemble the PiPower

After getting familiar with the components in the package, we start to assemble PiPower.

In the next steps, there are a lot of details you need to notice, especially the assembly position of the battery and the clear acrylic back cover.

  1. Attach the Adhesive Tape to the back.

    _images/assemble1.png
  2. Then stick the battery on and plug it in.

    _images/assemble2.png
  3. Bind the battery wires with a cable tie.

    _images/assemble3.png
  4. Now screw in four sets of standoffs.

    _images/assemble4.png
  5. Mount the Raspberry Pi on top.

    _images/assemble5.png
  6. Secure a protective plate at the bottom.

    _images/assemble6.png
  7. Plug in the USB-C cable to power the Raspberry Pi.

    _images/assemble7.png
  8. PiPower needs to be activated with the USB-C cable at the charge port the first time you use it or re-plug the battery

    _images/assemble8.png

    Warning

    When you put the battery in for the first time or when the battery is unplugged and put in again, the battery will not work properly, at this time, you need to plug the Type C cable into the charging port to turn off the protection circuit, and the battery can be used normally.

Features

_images/media2.png
  • Pass Through Charging

  • Shutdown Current:< 0.5mA

  • Input:
    • USB Type-C, 5V/3A

    • Battery Input

  • Output:
    • USB Type-A, 5V/3A

    • 2x4P P2.54 pin headers

  • Charging Power:7.4V/1A 7.4W

  • Equipped Battery
    • Type: 3.7V Lithium-ion batteries x 2

    • Capacity: 2000mAh

    • Connector: PH2.0, 5P

  • Over Discharge Protection Voltage:3.2V

  • Overcharge Protection Voltage:4.2V

  • Dimension: 90mm x 60mm x 24.9mm

  • On-board Indicators
    • 1 x Charging Indicator (CHG)

    • 1 x Power Indicator (PWR)

    • 4 Battery Indicators (D4 ~ D7)

About Charge and Discharge

Switch Power Path

PiPower V2 has the function of integrated power, which can automatically switch the power path to reduce battery consumption.

  • If an external power supply is connected, the 5V output is directly output from the external power supply, and the power switch can be used to turn it on or off. Additionally, the external power supply can charge the battery at low current.

  • When the external power supply is unplugged, PiPower switches to battery step-down power supply, seamless switching to protect the device.

Charging Power

Charging current will be switched according to the state of the power switch.

  • PiPower does not provide power to external devices when the power switch is off. This time, the charging power is 7W, and it takes about 2 hours to charge from 0% to 100%.

  • External power supply will power the connected device directly when the power switch is on. Charging power is reduced to less than 1W to ensure power supply current.

Over-discharge Protection

When the single battery voltage is below 3.2V, the battery protection activates and the battery is no longer discharged.

When the battery is unplugged, due to the mechanism of the on-board over-discharge protection circuit, the voltage will be considered too low, thus activating the protection circuit; when you replug the battery into the PiPower, the battery will not work properly, at this time, you need to plug the Type C cable into the charging port to turn off the protection circuit, and the battery can be used normally.

Overcharge Protection

Charging ends when the total battery voltage reaches 8.4V.

Charge Balance

When a single battery exceeds 4.2V, the voltage divider resistor channel conducts and the battery charging current is reduced or even discharged.

Temperature

When the output power reaches the maximum nominal 5V/3A, the temperature of DC-DC buck chip U1 will rise to about 70-80 degrees Celsius, so be careful not to touch it to prevent burns and keep ventilation. When the temperature reaches the DC-DC protection temperature of 75 degrees Celsius, the DC-DC will shut down to prevent overheating damage.

Battery Indicators

The relationship between the battery indicators and voltage is as follows:

  • 4 LEDs all on: voltage > 7.8V

  • 3 LEDs on: voltage > 7.36V

  • 2 LEDs on: voltage >6.96V

  • 1 LED on: voltage > 6.6V

  • 4 LEDs all off: voltage <6.6V,at this time,batteries need to be charged.

External Battery

_images/ex_btra.png

You can connect your own battery using the Screw Terminal.

Warning

Do not connect the external battery and the included battery at the same time!

The external battery only supports two 3.7V lithium batteries connected in series. The interface has three pins: “+”, “M”, and “-”. They should be connected to the battery’s positive terminal, the middle of the two batteries, and the battery’s negative terminal, respectively.

The PiPower board has an onboard battery protection circuit, offering over-discharge, overcharge, and overcurrent protection. Therefore, it’s recommended not to use batteries with their own protection boards.

The ‘M’ interface primarily serves the board’s protection circuit for single-cell battery protection and balanced charging currents during charging. If you don’t require protection and balanced charging features, you can omit connecting to the ‘M’ interface.

_images/ex_btr.png

About IO Pins

_images/io_pin.png

In order to meet the DIY needs of customers, multiple signal pins are provided on the PiPower, but they are not soldered by default.

  • GND: Ground input

  • BT_LV: Get the battery voltage pin. The voltage of this pin is equal to 1/3 of the battery voltage.

  • IN_DT: Input detect pin. Used to determine if there is USB power input, if so, this pin outputs high.

  • CHG: Charging status indication pin. This pin is high when charging.

  • LO_DT: Battery low voltage status pin. In normal state, this pin is low. When low battery voltage is detected, this pin is high.

  • EN: Switch signal pin. the EN pin can be connected to an external switch, put the pin to ground, the PiPower is off. The external switch can not use self-recovery button or key, etc. The EN pin is only effective when the on-board switch is turned on.

  • GND: Ground input

  • LED: Power indicator pin. Output 5V at power on, need to add current limiting resistor in the middle when connect an external LED.

  • GND: Ground input

About Battery

_images/2battery.jpg
  • VCC: Battery positive terminal, here there are two sets of VCC and GND is to increase the current and reduce the resistance.

  • Middle: To balance the voltage between the two cells and thus protect the battery.

  • GND: Negative battery terminal.

This is a custom battery pack made by SunFounder consisting of two 3.7V 18650 batteries with a capacity of 2200mAh. The connector is PH2.0-5P, which can be charged directly after being inserted into the PiPower.

Safe Shutdown for Raspberry Pi using PiPower

The PiPower board provides several expansion pins that can be leveraged to enable functionalities like a safe shutdown for Raspberry Pi. Here’s a detailed breakdown of these pins and their functions.

_images/io_pin.png
  • GND: Ground connection.

  • BT_LV: Indicates the battery voltage, which is 1/3 of the actual battery voltage.

  • IN_DT: Helps determine if USB power is connected. Outputs high when USB power is detected.

  • CHG: Signals when the device is charging.

  • LO_DT: Signifies low battery voltage status. Outputs high when low battery is detected.

  • EN: Serves as a switch signal. When connected to an external switch and grounded, it turns off the PiPower. This is effective only when the on-board switch is active.

  • LED: Provides power indication. Outputs 5V when powered on. When connecting an external LED, a current limiting resistor is necessary.

Note

These pins are not soldered. You’ll need to solder them using a soldering iron.

For this project, we’ll be focusing on the IN_DT, CHG, and LO_DT pins to determine if an external battery is present, if the USB charging cable is plugged in, and if the battery is low. This ensures the Raspberry Pi shuts down safely when the battery level is low.

Warning

Do not plug in both the external battery and the included battery simultaneously!

Wiring

This table showcases how the PiPower should be connected to the Raspberry Pi:

PiPower

Raspberry Pi

IN_DT

GPIO17

CHG

GPIO18

LO_DT_PIN

GPIO27

GND

GND

Download and Test

Sample code for the safe shutdown is provided:

  1. Download from PiPower Github or clone using:

    git clone https://github.com/sunfounder/pipower.git
    
  2. Navigate to the examples directory:

    cd pipower/examples
    
  3. Run the test program to verify the Raspberry Pi can read the power states correctly:

    python3 read_all.py
    

You can simulate different power states by unplugging the USB cable, removing the battery, or altering the Raspberry Pi’s pin connections. The printed messages will indicate the power state. For instance, if the power is supplied only by the battery, the following message will be displayed:

External power disconnected
Not charging
Battery OK

Warning

Never connect both the external battery and the built-in battery at once!

Setup Safe Shutdown

To enable the safe shutdown functionality:

  1. In the pipower/examples directory, execute:

    sudo bash enable_safe_shutdown.sh
    
  2. Restart the Raspberry Pi:

    sudo reboot
    

With this setup, your Raspberry Pi will shut down automatically in cases of not charging or low battery.

Advanced Configurations

For those looking for more customization, you can add further actions in safe_shutdown.py. Insert any necessary code under # Do some stuff before shutting down to execute specific actions before shutting down, such as sending a notification to your phone or shutting down certain services.

Remember to run enable_safe_shutdown.sh if you make changes to safe_shutdown.py.

sudo bash enable_safe_shutdown.sh

FAQ

PiPower not working?

When you put the battery in for the first time or when the battery is unplugged and put in again, the battery will not work properly.

This is because when the battery is removed, due to the mechanism of the on-board over-discharge protection circuit, the voltage will be considered too low, thus activating the protection circuit;

At this time, you need to plug the Type C cable into the charging port to release the protection circuit, and the battery can be used normally.