From Geekworm
Jump to navigation Jump to search

The following test is base on '2020-02-13-raspbian-buster.img'

Python version: V2.7

1. Enable I2C funcion on Raspbian:

sudo raspi-config

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


Select "OK"

Select "Finish" to return to the command line and reboot your raspberry pi.

sudo reboot

2. Install necessary software (python and i2c tool library)

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

3. Download x728 setup scripts:

git clone https://github.com/geekworm-com/x728.git
cd x728

4. Install script&reboot:

sudo bash x728.sh
printf "%s\n" "alias x728off='sudo x728softsd.sh'" >> ~/.bashrc 
sudo reboot

5. Set and Read the RTC time

#If you need to set the system time for any reason you can use the following command :  
date -s "5 MAR 2019 13:00:00"
#Write the system date and time to the RTC module after your correct the system date and time :  
sudo hwclock -w
#Read the date and time back from the RTC module:  
sudo hwclock -r

6. How to reading battery voltage and percentage, this is the sample code, you can modify it by your request.

sudo python x728bat.py

7. Power off command on Raspbian from software


8. Testing AC power off/loss or power adapter failure detection (need to shor the 'PLD' pin)

sudo python x728pld.py

Return to X728

Add your comment
Geekworm welcomes all comments. If you do not want to be anonymous, register or log in. It is free.

Anonymous user #2

3 months ago
Score 0++

I am getting an error when trying run the x728bat.py script. Below is the information I am getting on the Raspberry Pi 4.

sudo python x728bat.py Traceback (most recent call last): File "x728bat.py", line 3, in <module> import smbus

ImportError: No module named smbus

Anonymous user #1

3 months ago
Score 0++
Where are the additional files. The git only has the setup script. But the script calls for the files, which are absent. Any help?


3 months ago
Score 0++
The setup script creates all files on the fly. If you edit it you will see them.


4 months ago
Score 0++

Managed to get my new x728 going. Solid hardware. But am getting the following output from x728bat.py.

What does the Voltage at 4.21V mean? It's far from the 3.7V nominal from the batteries, and from the 5V required for the Raspberry Pi.

And 103% for the capacity? The script expects 100 to print "Battery FULL", so there is a fix in need here.

Voltage: 4.21V Battery: 103%