Changes

Jump to navigation Jump to search

X728-Software

2,430 bytes added, 01:09, 23 July 2023
no edit summary
{{GD Template Impl}}
The following test <big>Although this installation tutorial is base on '2020still available, but we strongly recommend that you use [[X728-02-13-raspbian-busterscript]] new tutorial, and we no longer maintain this page.img'</big>
<hr/> The following test is base on [https://www.raspberrypi.com/software/operating-systems/ 2022-01-28-raspios-bullseye-armhf.zip] Python version: V2.7is 3;
1. Enable I2C funcion on Raspbian:
sudo raspi-configreter to [[How to enable I2C]]
Select 5 Interfacing Options 2. Login via teminal window, then update & upgrade & install necessary software (python and then i2c tool library) sudo apt-get update sudo apt-get upgrade P5 I2C sudo apt-get -y install i2c- Enable/Disable automatic loading. A prompt will appear asking Would you like the ARM I2C interface to be enabled?, select "Yes" 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 sudo i2cdetect -y 1 [[File:Rpi-configX728x-1i2c.jpg|nonepng]] #36 - the address of the battery fuel gauging chip #68 - the address of the RTC chip #Different x728 versions may have different values
[[File3. Download x728 setup scripts:Rpi cd ~ git clone https://github.com/geekworm-config-5.jpg|none]]com/x728
[[File4. Install script&reboot:Rpi-config-6.jpg|none]]
Select "OK"Firstly please select your x728 version, please use x728-v2.1.sh for x728 v2.1 and v2.2 and '''v2.3''' sudo bash x728-v2.1.sh #New add buzzer supportor sudo bash x728-v2.0.shor Select "Finish" to return to the command line and reboot your raspberry pi sudo bash x728-v1.0.shthen
sudo reboot
2. Install necessary software (python and i2c tool library) sudo apt-You can get install the following python-smbus sudo apt-get install i2c-tools  3. Download x728 setup scripts: git clone https:file in /home/github.compi/geekworm-com/x728.git cd x728fold:
4. Install script&reboot: sudo bash x728x728bat.shpy # Reading battery voltage printf "%s\n" "alias x728off='sudo x728softsdx728pld.sh'" >> ~py # Testing AC power off/loss or power adapter failure detection, added buzzer function on v2.bashrc 1 sudo rebootx728plsd.py # Testing Auto shutdown when AC power loss or power adapter failure
5. Set and Read the RTC time
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.pyor sudo pyton /home/pi/x728bat_v1.2x728bat.py<pre>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 [[File:X728 V1-bat-2.3, in fact this script also fit to x728 old version, jpg]]you can found this x728bat_v1.3.py file in /home/pi/x728 folder after you execute the command git clone successfully.Please refer to 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: sudo crontab -e[[File:Crontab-step1.png]] Choose "`1`" then press Enter Add a line at the end of the file that reads like this: @reboot python /home/pre>pi/x728bat.py[[File:X728-crontab.png|800px]] Save and exit. In nano, you do that by hitting CTRL + X, answering Y and hitting Enter when prompted.
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 shor short the 'PLD' pinon v1.x), also test the buzzer function on v2.1 cd ~ sudo python3 x728pld.py or
sudo python x728pld.py
[[File:X728-pld-2.jpg]]
 
PS:
 
1. X728pld.py is '''ONLY''' a sample code file, you can modify it according to your own needs
 
2. The buzzer is controlled by software. It is found that some customers do not know how to turn off the buzzer's warning sound. Here is a reminder.
 
[[File:X728-buzzer.png|800px]]
 
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:
* [[File:MAX17040-MAX17041.pdf]]
 
*[https://www.sparkfun.com/datasheets/Components/DS1307.pdf I2C address: 0x36 for battery fuel gauging, 0x68 for RTC]
 
References:
*[https://www.instructables.com/Raspberry-Pi-Tutorial-How-to-Use-a-Buzzer/ Raspberry Pi Tutorial: How to Use a Buzzer]
*[https://github.com/arbowl/cyberdeck-battery-indicator/ Battery Indicator Script Share by Drew]
Return to [[X728]]

Navigation menu