UPS Module Mini

From Waveshare Wiki
Jump to: navigation, search
UPS Module Mini
UPS Module Mini.jpg






This is a mini uninterruptible power supply (UPS) module that supports simultaneous charging and discharging. It can provide a stable 5V voltage output and supports I2C communication, allowing for access to information such as battery voltage, current, power, and charging status.


  • Mini UPS expansion board for easy soldering or integration into mobile robots and industrial control equipment.
  • I2C bus communication, monitoring the battery's voltage, current, power, and remaining capacity in real time.
  • Onboard multiple function pins, provide two charging and discharging methods via pads and pin headers.
  • Multiple battery protection circuits: overcharge/discharge protection, over current protection, short circuit protection, and reverse protection, along with the equalizing charge feature, more safe and stable.
  • Onboard 5V regulator, up to 2.5A continuous output current.
  • Onboard warning indicators, easy to check if the battery is connected correctly and the charging status.
  • Comes with online development resources and a manual.


  • Output voltage: 5V
  • Charging power: 5V
  • Control interface: I2C
  • Batteries: 350mAh 10440 Lithium Battery 3.7V (NOT included)
  • Dimensions: 61 × 38mm

Hardware Description

Pin Function
IN Power input (5V 3A)
OUT UPS output (5V 2.5A)
GND ground
UPS OFF turn off the UPS power output when connected to the PWR pin
BOOT Batteries activation (pull low for 500ms and then pull high)
CHARGE Charge indication (low level indicates charging)
SCL I2C clock
SDA I2C data
PWR UPS ON/OFF (turn off UPS power output when connected to UPS OFF pin)

Note 1: When initially connecting the battery, pay attention to whether the WARNING LED is on. If the LED is on, it indicates that the corresponding battery is connected reversely. Charging is prohibited when the battery is connected reversely.

Note 2: When initially connecting the battery, there may be no power output. Press the BOOT button on the circuit board to activate the battery protection chip and enable power output.

Note 3: To charge the product, use the power supply provided with the product. Using other power chargers may result in unstable power output with excessive ripple, which can damage the product.

Note 4: If the insulation pad on the positive electrode of the battery is removed or damaged, it is recommended not to continue using it as it can easily lead to a short circuit and fire. When removing the battery, avoid using a screwdriver to pry the positive electrode, as it can easily cause a short circuit. Instead, you should focus on prying the negative electrode of the battery.


  • Li-ion and Li-po batteries are quite unstable. They may cause fire, personal injury, or property damage if they're not properly recharged or used.
  • Do not reversely connect the polarities when recharging or discharging the battery. Do not use an inferior charger/charging panel to recharge the battery.
  • Do not mix use old batteries with new ones, avoid using batteries of different brands.
  • When buying a Lithium battery, should always make sure the battery specification is compatible with the expansion board. Choose batteries from the formal manufacturer, and ensure the batteries will work stably and safely by aging test.
  • Lithium batteries have limited cycle life, they will also deteriorate as time goes by. Should be replaced with new ones when the batteries reach their max cycle life, or work over two years, whichever comes first.
  • Should be placed carefully and properly, keep it away from inflammable and explosive articles, away from children, and avoid any safety accident caused by careless storage.

How to Use the Demo

Working with Raspberry Pi

Hardware Connection

Note: Here it only communicates with the host, if you want to charge and discharge, you need to connect IN and OUT.

UPS Module Pin Raspberry Pi (BCM)

Demo Usage

Enable I2C Interface

  • Open the Raspberry Pi terminal, and run the following commands to enter the configuration interface:
sudo raspi-config
Select Interfacing Options -> I2C -> Yes to enable the I2C interface

UPS Module Mini for rpiuse01.jpg
And then reboot the Raspberry Pi:

sudo reboot

Please make sure that the I2C is not occupied by other devices, you can check in the middle of /boot/config.txt.

Install Libraries

#Open the Raspberry Pi terminal and run the following commands
tar zxvf bcm2835-1.71.tar.gz 
cd bcm2835-1.71/
sudo ./configure && sudo make && sudo make check && sudo make install
# For more, you can refer to the official website at
git clone
cd WiringPi
gpio -v
# Run gpio -v and version 2.70 will appear, if it does not appear it means there is an installation error
sudo apt-get update
sudo apt-get install python-pip
sudo pip install RPi.GPIO
sudo pip install smbus
sudo apt-get update
sudo apt-get install python3-pip
sudo pip3 install RPi.GPIO
sudo pip3 install smbus

Download the Test Demo

Open the Raspberry Pi terminal and run the following commands:

sudo apt install unzip -y
cd ~
sudo wget
sudo unzip
cd UPS_Module_Mini_Code/Raspberrypi/

Run the Test Demo

Please run the following commands in the Raspberry Pi. Otherwise, you can not find the directory if it is not in the index.

  • Recompile and it may take a few seconds to compile:
cd ~/UPS_Module_Mini_Code/Raspberrypi/c/
sudo make clean
sudo make -j
sudo ./ups_module
d ~/UPS_Module_Mini_Code/Raspberrypi/python/
sudo python
  • Run the demo corresponding to the screen you used, and the demo supports python2/3.

Running Effect

  • From top to bottom, the parameters are battery voltage, battery current, battery power, and whether it is charging or not.
  • In charge: charging.
  • In discharge: being discharged.
  • The chart below shows the actual value, not the maximum value.

UPS Module Mini for rpiuse 05.jpg


UPS Module Mini for rpiuse 06.jpg

C Library Selection

  • We use our own IO library by default: USE_DEV_LIB.
  • This can be changed by modifying the Makefile with the following command:
  • Choose one of the three, and you need to remove the corresponding comment and add the comments to the others. Otherwise, it will runs the last one.
  • For example, if you need to use the wiringpi library for compilation, set it like this:

Note: You need to reboot Raspberry Pi after using the BCM2835 library, otherwise you can't use Python and other libraries of C programs.

Raspberry Pi Pico

Hardware Connection

Note: Here it only communicates with the host, if you want to charge and discharge, you need to connect IN and OUT.

UPS Module Pin Raspberry Pi Pico

C/C++ Development Environment Installation

MicroPython Development Environment Installation

*After installing, please configure the language and the environment for the first time. Note that we should choose the Raspberry Pi option in the board environment.


  • Configure the Micrpython environment and select the Pico port.
    • First connect the Raspberry Pi Pico to the computer, left-click on the configuration environment option in the lower right corner of Thonny --> select configure an interpreter.
    • In the pop-up window bar, select MicroPython (Raspberry Pi Pico), and select the corresponding port.

Raspberry Pi Pico002.png

  • Click OK to return to the main interface of Thonny, download the firmware library to Pico, and then click the stop button to display the currently used environment in the Shell window.
  • Pico download firmware library method in Windows: Press and hold the BOOT button and connect to the computer, release the BOOT button, and a removable disk will appear on the computer and copy the firmware library into it.

In the Raspberry Pi

  • Open the Raspberry Pi terminal and execute:
sudo apt install unzip -y
cd ~
sudo wget
cd ~/UPS_Module_Mini_Code
cd Pico/c/build/

How to Use the Demo

  • Please operates the following tutorial on Raspberry Pi, but due to the multi-platform and portable nature of CMake, it can also be compiled successfully on PC, but the operation is slightly different and requires your own judgment.
  • To perform the compilation, make sure that in the c directory:
cd ~/UPS_Module_Mini_Code/Pico/c/

Create and enter the build directory, and add the SDK: ../../pico-sdk is the directory of your SDK. There is a build in our sample application, just enter it directly.

cd build
export PICO_SDK_PATH=../../pico-sdk
(Note: Be sure to write the right path to your own SDK)

Execute cmake to automatically generate the Makefile file:

cmake ..

Execute make to generate the executable file, you may wait for a long time as it is the first time to be compiled.

make -j9

After compiling, uf2 file will generate. Press the button on the Pico board, Pico can connect to the USB port of the Raspberry Pi via a Micro USB cable, and then release the buttons. After connecting, Raspberry Pi will automatically identify a movable disk (RPI-RP2), and copy main.uf2 in the build file to the recognizable movable disk (RPI-RP2).

cp main.uf2 /media/pi/RPI-RP2/
  • 1. On the Raspberry Pi, copy ~/UPS_Module_Mini_Code/Pico/python/rp2-pico-20230329-unstable-v1.19.1-994-ga4672149b.uf2 to Pico.
  • 2. Open Thonny IDE on the Raspberry Pi (click Raspberry Pi logo -> Programming -> Thonny Python IDE), and you can check the version information in Help -> About Thonny.

To ensure your version that your version includes the package supported Pico, you can click Tools -> Options... -> Interpreter, and choose MicroPython (Raspberry Pi Pico and ttyACM0 port). As shown below:
If your current Thonny version has no package supporting Pico, you can enter the following commands to update Thonny IDE.

sudo apt upgrade thonny

3. Click File -> Open... -> ~/UPS_Module_Mini_Code/Pico/python/, and then run the script.


  • Click here to download, decompress it to the Pico file folder.


  • After entering Pico\c, you can open the project with vs code.

1.28inch Touch LCD pico.jpg

  • Choose the Compiler.

1.28inch Touch LCD pico2.jpg

  • Start to compile.

1.28inch Touch LCD pico3.jpg

  • Finish.

1.28inch Touch LCD pico4.jpg

  • Copy the UPS_Module_Mini.uf2 in build to Pico, and then it can automatically run the demo.

1.28inch Touch LCD pico5.jpg


  1. Press the BOOTSET button on the Pico and connect the Pico to the USB port of the computer with a Micro USB cable. Release the button when the computer identifies a movable disk (RPI-RP2).
  2. Copy rp2-pico-20230329-unstable-v1.19.1-994-ga4672149b.uf2 file in the python directory to the recognizable movable disk(RPI-RP2).
  3. Open Thonny IDE (Note: please use the latest version of Thonny, otherwise there is no Pico supporting package. Currently, the newest version in Windows is v3.3.3.)
  4. Click Tool -> Setting -> Explainer. select the Pico and the corresponding port as shown below:
  5. File -> Open ->, click to run, the effect is shown as below.
    1.28inch Touch LCD pico7.jpg

We provide a simple demo for you...

Running Effect

  • Information content to view the Raspberry Pi operation effect introduction.


  • You need to open Pico's virtual serial port to view information through the serial debugging assistant.


  • After running the demo, you can view the information in the shell.

MicroPython (For Raspberry Pi Pico)

  • The basic library can be viewed here and click here for more details.

Working with STM32

Hardware Connection

Note: Here it only communicates with the host, if you want to charge and discharge, you need to connect IN and OUT.

Module Pin STM32F103RB

Download Example

The demos are developed based on the HAL library.

Click to download the demo, unzip it, and open UPS_Module_Mini_Code\STM32\UPS_Module_Mini\MDK-ARM directory of UPS_Module_Mini.uvprojx to see the demo.

UPS Module Mini for stm32 use02.jpg

Open main.c, you can see the demo, and then recompile to download.

UPS Module Mini for stm32 use03.jpg

Running Effect

  • Need to open the STM32's virtual serial port to view the information through the serial debug assistant.
  • Information content to view the operation of the Raspberry Pi effect introduction.

Working with Arduino

Note: The demos are tested on Arduino Uno, if you need to use other models of Arduino you need to make sure that the pins are connected correctly.

Arduino IDE Installation

Hardware Connection

Note: Here only communicate with the host, if you want to charge and discharge, you need to connect IN and OUT.

UPS Module Pin Arduino uno

Running the Demo

Click to download the demo, and unzip it. Note the demo is in UPS_Module_Mini_Code\Arduino\UPS_Module_Mini.

UPS Module Mini for arduino use.jpg

Install the Arduino IDE, and then run the UPS_Module_Mini.ino file.
Open the program, and select the development board as Arduino UNO.
1.9inch LCD Module Arduino11.jpg
Select the corresponding port.
1.9inch LCD Module Arduino12.jpg
And then click to compile and download.
UPS Module Mini for Arduino use 03.jpg

Running Effect

  • You need to open the virtual serial port of Arduino UNO to view the information through the serial debugging assistant.
  • Information content to view the operation of the Raspberry Pi effect introduction.




Related Resource



Technical Support

If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 PM GMT+8 (Monday to Friday)