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

From All for Raspberry Pi, Arduino, Lattepanda, Orange Pi, Pine64 | by Geekworm
Revision as of 18:22, 7 November 2019 by Admin (talk | contribs)
Jump to: navigation, search

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

We test it base Raspbian Stretch system.

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"

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

Download the required script


Install the script

sudo bash

Setting up the command to turn off X750 from software

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

Reboot the Raspberry Pi

sudo reboot

Reading battery voltage and percentage

sudo python

Powering off the Raspberry Pi from software