power mgmt - ups shield  
  x1200 x1201 x1202  
     
 
  Home       Be Our Distributor      Custom Products      OEM/ODM      What We Do      Contact  
     
 
      Software Tutorials       software  
     
 

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/x120x.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
 

#36 - the address of the battery fuel gauging chip
   
 3.0 Reading battery voltage & percentage
3.1 Run the command to read battery voltage and percentage
  pi@raspberrypi:~/x120x $  sudo python3 bat.py 
   
3.2 Change the battery low voltage to implement safe shutdown. default is less than 3.20Vdc.
  pi@raspberrypi:~/x120x $  sudo nano bat.py 
   
  Note: the voltage range must be 3.00~4.10vdc.
   
3.3 Save and exit. In nano, you do that by hitting CTRL + X, answering Y and hitting Enter when prompted.
 4.0 AC Power loss or power adapter failure detection (PLD)
4.1 Execute the command to initiate power loss detection (PLD)
  pi@raspberrypi:~/x120x $  sudo python3 pld.py 
  Disconnect the power adapter and observe the detection of the power loss.
5.0 Control battery charging - for advanced users only
5.1 To disable battery charging
  pi@raspberrypi ~ $  pinctrl set 16 op dh
   
5.2 To enable battery charging
  pi@raspberrypi ~ $  pinctrl set 16 op dh
   
 
 
 
   
   
© 2023 SupTronics Technologies Limited, All Rights Reserved.