How to read the battery capacity via I2C on X750&725


This is the guide of how to read the battery capacity via I2C on X750&725:

We test it base Raspbian Stretch system.

1. Enable I2C function on the Raspbian

sudo raspi-config

Select '5 Interfacing Options' and then 'I2C - Enable/Disable automatic loading'. A prompt will appear asking 'Would you like the ARM I2C interface to be enabled?', select "Yes"

2. Once you have logged into your Raspberry Pi from the command line, run the following command to install i2c-tools

sudo apt-get install python-smbus
sudo apt-get install i2c-tools

3. Download the required script

git clone https://github.com/geekworm-com/x750.git
cd x750
chmod +x x750.sh

4. Install the script

sudo bash x750.sh

5. Setting up the command to turn off X750 from software

printf "%s\n" "alias x750off='sudo x750shutdown.sh'" >> ~/.bashrc

6. Reboot the Raspberry Pi

sudo reboot

7. Powering off the Raspberry Pi from software

x750off

8. Reading battery voltage and percentage

sudo python x750ups.py

Customers often ask if we support automatic and safe shutdown at low battery capacity? Our suggestion is: You can refer to the A file and the B file to program this idea yourself: The idea is to read the current voltage or battery capacity cyclically, and then judge the program to execute the automatic shutdown command when it is low or low voltage, of course This low battery or low voltage value is an empirical value, and you can specify it yourself in the program.