X728-Software

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"

Rpi-config-1.jpg
Rpi-config-5.jpg
Rpi-config-6.jpg

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_v1.2.py

or

sudo pyton /home/pi/x728bat_v1.2.py

UPDATED!

we add a new python script file (x728bat_v1.3.py) to implement automatic shutdown function when the battery is low voltage due to the hardware ASD function is remove in X728 V1.3, in fact this script also fit to x728 old version,

You can found this x728bat_v1.3.py file in /home/pi/x728 folder after you execute the command git clone successfully.

User Guide: https://github.com/geekworm-com/x728 to know more details;


7. Power off command on Raspbian from software

x728off

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 #12

22 days ago
Score 0++
when I attached X735 v1.3 the system hangs in a loop. the power led of x728 v2.5 and 735 are on. pi starts. after a few sec it willstop and the power led of 735 is off. then it will restart. any idea?

Harry

one day 2 hours 13 minutes ago
Score 0++

CAN'T use x728 with X735, please use the X728-A1 if you want heatsink.

Thanks.

Anonymous user #9

25 days ago
Score 0++
"x728off" (and "sudo /usr/local/bin/x728softsd.sh") say "X728 Shutting down..." but then never shut down. Do you know why this is? Using a fresh install of the latest Raspbian OS and followed the instructions fully.

Anonymous user #11

one month ago
Score 0++

These can be converted to Python3 with :

Apt-get install 2to3

Changing the Python env at the top of the files etc.

Anonymous user #10

one month ago
Score 0++
I want to use this UPS to power a Freenove 3 wheeled smart car, is this possible? as both have an I2C?

Anonymous user #9

one month ago
Score 0++

If you are getting the error: "IOError: [Errno 110] Connection timed out"

for x728bat.py, check and see no other programs are using GPIO3. I had a power button shutdown script that ran on startup to turn the pi off and it was preventing the HAT from reading that pin. I simply uninstalled and used the supported shutdown button feature for this board.

Anonymous user #7

2 months ago
Score 0++

The shutdown script doesn't work for me. I get an error on line 5 which is the line: echo "$BUTTON" > /sys/class/gpio/export I get: "echo: write error: Device or resource busy" Of course lines 6 and 7 give errors also.

Any idea what this is (BTW, I'm running this on a Raspi 4 4GB with 7" Raspi display)

Anonymous user #9

25 days ago
Score 0++
It appears that this will only happen if you run the command multiple times after a fresh reboot. The real problem is that the first time you run it, it won't work for some reason.

Anonymous user #5

3 months ago
Score 0++

Adding the below to my config turns the x728 off after shutdown

dtoverlay=gpio-poweroff,gpiopin=13

Anonymous user #6

2 months ago
Score 0++

I did not see an answer to this question: How do you turn the UPS off after an hour with no power?

also, How do you turn on the x728 and boot the PI with power applied to the x728 and then soft-shutdown the PI and then turn off the x728 after the power is removed?

Anonymous user #5

3 months ago
Score 0++

How do you turn the UPS off after an hour with no power?

I've set up my PI to shutdown after an hour with no power reading GPIO6 but I cant get it to turn the UPS off. This means when I apply power again nothing happens as the UPS or PI never actually shutdown.

Anonymous user #4

3 months ago
Score 0++
I need to be able to shutdown the whole rig (RPi4 and x728) from a script. Is that possible?

Anonymous user #2

9 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 #8

one month ago
Score 0++
Use python3, not python.

Anonymous user #11

one month ago
Score 0++

if you are using python3 make sure that you install:

pip3 install smbus smbus2

for GPIO, you may have to set the following: export CFLAGS=-fcommon

pip3 install RPi.gpio

Anonymous user #1

9 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?

Pmsr

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

Pmsr

9 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%

Anonymous user #3

3 months ago
Score 0++

Hi Pmsr, the Voltage you see is coming from the batteries. It is a very usefull indication of the quality of them.

4.2V is the fully charged value. 3.7V is the steady value over a relative long periode without charging.