Power bank & UPS - XUPS2
  Getting Started - software
   
 
  Home       Be Our Distributor      Custom Products      OEM/ODM      What We Do      Contact  
     
 
      Software Tutorials   hardware   software  
     
 

This sample Python script is designed to run on a Raspberry Pi 5. It measures and reports key electrical parameters, including battery charging/discharging voltage and current, as well as the output voltage and current of both the 12V and 5V UPS power rails.

 

This tutorial assumes you've already set up a Raspberry Pi with Raspbian12(bookworm). For help installing the Debian-based OS on your Pi, check out the docs on Raspberrypi.org.

 
   
     
 
  1.0 Editing the EEPROM configuration 
1.1 From the command line or Terminal window start by running the following command :
pi@raspberrypi ~ $  sudo rpi-eeprom-config -e
 

Change the setting of  POWER_OFF_ON_HALT from 0 to 1 ,
Add PSU_MAX_CURRENT=5000 at the end of the file that reads like this:

1.2 Reboot your Raspberry Pi 5 to make the change take effect.
  pi@raspberrypi ~ $  sudo reboot
 
  2.0 Configuring the Raspberry Pi for I2C
2.1 From the command line or Terminal window start by running the following command :
  pi@raspberrypi ~ $  sudo raspi-config
  This will launch the raspi-config utility. Select "Interfacing Options"
 
   
2.2 Highlight the “I2C” option and activate "<Select>"
   
   
2.3 Select and activate “<Yes>
 
   
2.4 Highlight and activate “<Ok>
 
   
2.5 Activate "<Finish>", this will exist the raspi-config utility.
 
   
2.6 Update your Pi and Install the required dependencies
  pi@raspberrypi ~ $  sudo apt-get update             
  pi@raspberrypi ~ $  sudo apt-get upgrade -y
  pi@raspberrypi ~ $  sudo apt-get install python3-pip
   
2.7 Download the required scripts
  pi@raspberrypi ~ $  git clone https://github.com/suptronics/xups2.git
   
2.8 Reboot the Raspberry Pi
  pi@raspberrypi ~ $  sudo reboot
  The Raspberry Pi will reboot and the interface will be enabled.
   
2.9 Once you have logged into your Raspberry Pi from the command line, run the command to see all the connected devices
  pi@raspberrypi ~ $  sudo i2cdetect -y 1
 



#40 - The INA219 sensor's I2C address for battery monitoring (charge/discharge)
#41 -
The INA219's I2C address for monitoring the UPS 12V output voltage and current.
#44 -
The INA219's I2C address for monitoring the UPS 5V output voltage and current.

   
3.0 Command to monitor battery charging & UPS output status
  pi@raspberrypi:~/xups2 $  sudo python3 xups2-pms.py
   
   
   
 
 
 
   
   
© 2024 SupTronics Technologies Limited, All Rights Reserved.