X729-Software

From Geekworm Wiki
Revision as of 16:06, 19 November 2022 by Harry (talk | contribs)
Jump to navigation Jump to search

The following test is base on 2022-09-22-raspios-bullseye-armhf.img.xz

Python version is 3;

1. Enable I2C funcion on Raspbian:

reter to How to enable I2C

2. Check & review I2C port

2.1 Login via teminal window, then update & upgrade & install necessary software (python and i2c tool library)

sudo apt-get update
sudo apt-get upgrade
sudo apt-get -y install i2c-tools python3-smbus python-smbus

2.1 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
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- 36 -- -- -- -- -- 3c -- -- -- 
40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --   
#36 - the address of the battery fuel gauging chip
#3c - OLED display
#40 - TI INA219 12-bit current/voltage/power monitor
#68 - the address of the RTC chip

PS: Please check if the OLED is inserted in the correct direction if you don't found the above i2c port

3. Setting up the power management script

3.1 Download x729 setup scripts:

cd ~
git clone https://github.com/geekworm-com/x729

3.2. Install script&reboot:

sudo bash pwr.sh
#Setting up the command to turn off X729 from software

printf "%s\n" "alias x729off='sudo x729softsd.sh'" >> ~/.bashrc 
#Reboot the Raspberry Pi
sudo reboot

3.3 Powering off the Raspberry Pi from software

 x729off 

4. Setting up the PWM cooling fan

cd ~
cd x729
python3 pwm_fan_control.py

4.1 Run the script at Raspberry Pi boot

sudo crontab -e
Crontab-step1.png

Choose "1" then press Enter

4.2 Add a line at the end of the file that reads like this:

@reboot python3 /home/pi/x729/pwm_fan_control.py
X729-2.png

4.3 Save and exit. In nano, you do that by hitting CTRL + X, answering Y and hitting Enter when prompted.

4.4 Run below script and you will get RPM value every second:

cd ~
cd x729
python3 read_fan_speed.py 

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 /home/pi/x728bat.py

X728-bat-2.jpg

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

But we hope that the script can be executed automatically when the Raspberry Pi board boots, we can use crontab system command to achieve it. Refer to How to add crontab job or refer to the following:

pi@raspberrypi ~ $  `sudo crontab -e`

Choose "`1`" then press Enter

Add a line at the end of the file that reads like this:

`@reboot python /home/pi/x728bat.py`

7. Power off command on Raspbian from software

x728off
  • x728off is safe shutdown command
  • press on-board blue button 1-2 seconds to reboot
  • press on-board blue button 3 seconds to safe shutdown,
  • press on-board blue button 7-8 seconds to force shutdown.

8. Testing AC power off/loss or power adapter failure detection (need to short the 'PLD' pin on v1.x), also test the buzzer function on v2.1

cd ~
sudo python3 x728pld.py
or 
sudo python x728pld.py

X728-pld-2.jpg

9. Testing Auto shutdown when AC power loss or power adapter failure

cd ~
sudo python3 x728pld.py
or 
sudo python x728plsd.py

uninstall x728 script

uninsatll x728 shell script, run the following command:

sudo ./uninstall_x728.sh

For the x728 old shell script, you also run this command to remove it, then re-install the x728 script.

FAQ

Q: We want to automatically shut down when the battery voltage is lower than a certain specified value, is it possible?

A: Please run the followng command to achieve this function.(Note: 3V is default shut down voltage value )

python3 /home/pi/x728/x728v2-asd.py &

X728-Chip-Specifications:

References:

Return to X728

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


Anonymous user #2

2 months ago
Score 0++
Is there any information and demo script on the current/voltage/power monitor data from address 40?

Anonymous user #3

2 months ago
Score 0++

1. OLED displays voltage and current output.

2. You can rfer to bat.py file

Anonymous user #1

7 months ago
Score 0++

i use raspberry pi4 (OMV) with x729

but not (fan & oled )working. how to run on booting?

Walker

7 months ago
Score 0++

Hello, first of all, to run the X729 fan or OLED, you need to run some instructions. For details, you can refer here:

fan

OLED