ONPOWER UPS HAT for Raspberry Pi

Introduction

DFRobot ONPOWER Raspberry Pi UPS hat is an uninterruptible power supply(UPS) expansion board for Raspberry Pi 3 Model B+/ 4 Model B development boards. This is a power management device specially designed for the Raspberry Pi. It can continue to supply power to the Raspberry Pi for a certain period of time in the case of an external power failure to avoid problems such as system damage and data loss caused by sudden power failure. The ONPOWER Raspberry Pi UPS hat supports USB TYPE-C power input, compatible with TYPE-C QC2.0/QC3.0, Huawei FCP and the other multiple rapid charge protocol. It can reduce the charging time while maintaining the maximum power output of 5V@3A. A 3000mAh 18650 battery can keep the system uptime for 3~4 hours, ensuring data security, but also enough to meet the needs of Raspberry Pi's daily use and mobile application scenarios. The hat has a mounting hole for DC fan, it can maintain the device running temperature. DFRobot ONPOWER Raspberry Pi UPS hat has an onboard RTC module, which we can set the time and control Raspberry Pi's power on and off via the software regularly. Cooperate with the mainboard's self-start function, it can realize timing boot/shutdown. DFRobot ONPOWER Raspberry Pi UPS expansion board uses a MAX17043 dedicated power detection chip, which is compatible with most lithium batteries on the market. The chip has its own algorithm, with the onboard LED, it can directly display the battery power capacity, and you can also get the power supply status through the serial port command.

Features

Specification

Board Overview

Board Overview Note: Please note the battery capacity, at least 3000mAh. Higher will be better.

Tutorial

Installation Diagram

ONPOWER UPS HAT Installation Diagram
  1. The fan can be fixed under the UPS board with M3x12 screws and M3 nuts (the side where the fan interface located)
  2. Insert the XH2.54 2x20P long pin header from the back side (the side where the fan interface located)
  3. Insert the female side of the row into the pin side of the Raspberry Pi, see the figure above for details.

UPS RTC(Real Time Clock) Tutorial

ONPOWER UPS HAT communicates with the Raspberry Pi through the I2C interface. We can set the time and the alarm, read the real time clock, and make timing on/off. Please download DFRobot UPS Python library, and put this folder on the desk of the Raspbian system.

Raspbian Desk

Open the I2C interface of the Raspberry Pi and enter through the terminal: sudo raspi-config

Open Raspberry Pi I2C

Select Interfacing Options-> I2C->Enable

Enable Raspberry Pi I2C

After we opened I2C interface,RTC can work now!

Change directory to DFRobot UPS Python Library Location:cd /home/pi/Desktop/DFRobot_raspberrypi_ups/python/examples/ups

Change directory

Enter Help Command, check all commands and explanations: python ups.py -p help

Enter Help Command

Help Commands

Help Commands

Examples: Synchronize the system time:python ups.py -p get_time

Synchronize the system time

There are many commands in UPS, please try more.

UPS Fan Tutorial

ONPOWER UPS HAT use BCM26(wiringPi code GPIO25;Physical pin 37) to control the fan.

Fan Driver

Sample Code

Open Thonny Python IDE, copy and paste the code, when the SoC temperature is higher than 55 degree, turn on the fan. When it is lower than 48 degree,turn off the fan.

from RPi import GPIO
from time import sleep

GPIO.setmode(GPIO.BCM) # USD BCM Pin mode

channel = 26    # BCM26(Physical pin 37)
start_temp = 55 # Startup threshold: 55(℃)
end_temp = 48   # Shutdown threshold: 48(℃)

GPIO.setup(channel, GPIO.OUT, initial = GPIO.LOW) # Initialize control pin
is_high = GPIO.LOW # GPIO Status flag

try:
    while True:
        # Get SoC temperature
        temp = open('/sys/class/thermal/thermal_zone0/temp')
        temp = int(temp.read()) / 1000

        if temp > start_temp and not is_high: # When the SoC temperature exceeds the startup threshold and the fan is off
            GPIO.output(channel, GPIO.HIGH)   # Turn on the fan
            is_high = GPIO.HIGH               # Mark the fan status as on

        elif temp < end_temp and is_high:     # When the SoC temperature is below the shutdown threshold and the fan is on
            GPIO.output(channel, GPIO.LOW)    # Turn off the fan
            is_high = GPIO.LOW                # Mark the fan status as off

        sleep(10) # 10s
except:
    pass
# Reset this pin when exiting
GPIO.cleanup(channel)

More Documents

Schematic

DFshopping_car1.png Get ONPOWER UPS HAT from DFRobot Store or DFRobot Distributor.

Turn to the Top