Difference between revisions of "X708-Software"
Line 121: | Line 121: | ||
[[File:X708-v2-fan.png]] | [[File:X708-v2-fan.png]] | ||
− | + | 9. Uninstall | |
− | + | <span style="color:#23AC38">pi@raspberrypi</span>:<span style="color:#50BEDB">~ $</span> cd x708v2/raspberry-pi-os/ | |
+ | <span style="color:#23AC38">pi@raspberrypi</span>:<span style="color:#50BEDB">~/x708v2/raspberry-pi-os $ </span>sudo bash uninstall.sh | ||
== For Ubuntu== | == For Ubuntu== |
Revision as of 16:34, 27 April 2022
For Raspberry Pi OS
The following test is base on '2020-02-13-raspbian-buster.img'
Testing is base on '2022-01-28-raspios-bullseye-armhf.img' on Feb. 28th, 2022;
Python version: V2.7
1. Enable I2C funcion on Raspbian;
Please refer to How to enable I2C
2. Updatesoftware and install necessary software (python and i2c tool library)
sudo apt-get update #sudo apt-get install python-smbus sudo apt-get install python3-smbus sudo apt-get install i2c-tools
3. Check if the i2c of the X708 is connected correctly
pi@raspberrypi: ~/x708v2 $ 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 -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --
36 - the address of the battery fuel gauging chip, and 36 is a hexadecimal number
If you can't find i2c address 36, it means the X708 is not connected properly, or your raspberry pi board is broken.
3. Download x708 setup scripts:
git clone https://github.com/geekworm-com/x708.git
This command will download the script installation file for X708
4. Install the script for power management
4.1 Enters the corresponding operating system scripts folder (raspberry-pi-os)
pi@raspberrypi:~ $ cd ~/x708v2/raspberry-pi-os/
4.2 Execute the installation script.
pi@raspberrypi:~/x708v2/raspberry-pi-os $ sudo bash pwr.sh
This command will generate 2 power management script files as follows:
- /etc/x708pwr.sh
- /usr/local/bin/x708softsd.sh
4.3 Create an alias x708off so that we can perform software shutdown from the command line, you can also change x708off to any name you like
pi@raspberrypi:~/x708v2/raspberry-pi-os $ printf "%s\n" "alias x708off='sudo x708softsd.sh'" >> ~/.bashrc pi@raspberrypi:~/x708v2/raspberry-pi-os $ sudo reboot Or force press the button of x708 for 8 seconds to shut down and then restart
4.4 Test software shutdown from command line after restart.
pi@raspberrypi:~/x708v2/raspberry-pi-os $ x708off
4.5 Press on-board button or external switch to test hardware safe shutdown
Press the switch for about 3 seconds until the power indicator flashes to execute hardware safe shutdown.
[NOTE]:
- After shutdown, press the onboard switch or external switch to turn on.
- If your test fails, it means that your installation failed, or the software environment is incorrect, please check whether you have installed the corresponding software package.
5. How to reading battery voltage and percentage, this is the sample code, you can modify it by your request.
pi@raspberrypi:~ $ cd ~/x708v2/raspberry-pi-os/ pi@raspberrypi:~/x708v2/raspberry-pi-os $ sudo python3 bat.py
****************** Voltage: 4.18V Battery: 100% Battery FULL ****************** Voltage: 4.17V Battery: 100% Battery FULL ****************** Voltage: 4.18V Battery: 100% Battery FULL ****************** Voltage: 4.17V Battery: 100% Battery FULL ******************
- In generally, you need to let the X708 fully charge and discharge several times before you can get more accurate voltage and power values.
- This script can also perform safe shutdown at specified voltage threshold (default voltage threshold is 3.00vdc), you can also modify this voltage threshold, but the voltage threshold range must be 2.5~4.1vdc.
6. Testing AC power off/loss or power adapter failure detection (PLD function)
pi@raspberrypi:~ $ cd ~/x708v2/raspberry-pi-os/ pi@raspberrypi:~/x708v2/raspberry-pi-os $ sudo python3 pld.py
1.Make sure your power adapter is connected 2.Disconnect and then connect the power adapter again to test 3.When power adapter disconnected, you will see: AC Power Loss or Power Adapter Failure 4.When power adapter reconnected, you will see: AC Power OK, Power Adapter OK Testing Started---AC Power Loss OR Power Adapter Failure--- ---AC Power OK,Power Adapter OK--- ---AC Power Loss OR Power Adapter Failure--- ---AC Power OK,Power Adapter OK---
7. Test Auto shutdown when AC power loss or power adapter failure
pi@raspberrypi:~ $ cd ~/x708v2/raspberry-pi-os/ pi@raspberrypi:~/x708v2/raspberry-pi-os $ sudo python3 plsd.py Testing Started---AC Power Loss OR Power Adapter Failure--- Shutdown in 5 seconds Connection closing...Socket close.
In fact, you can refer to this example code to implement your own shutdown logic. . . This requires you to have some python programming foundation.
8. Automatically control the cooling Fan
pi@raspberrypi:~ $ cd ~/x708v2/raspberry-pi-os/
You can control the fan running at high speed or low speed via modify the CPU temperature threshold in fan.py script file
9. Uninstall
pi@raspberrypi:~ $ cd x708v2/raspberry-pi-os/ pi@raspberrypi:~/x708v2/raspberry-pi-os $ sudo bash uninstall.sh
For Ubuntu
Base ubuntu-mate-20.04.1-desktop-armhf+raspi.img
1. Enable I2C
2. update & upgrade
sudo apt update sudo apt upgrade
3. Install necessary software
sudo apt install git python python3 python3-smbus python3-rpi.gpio python-rpi.gpio wiringpi -y
4.Download x708 setup scripts:
git clone https://github.com/geekworm-com/x708.git cd x708 chmod +x *.sh sudo bash install-ubuntu.sh sudo reboot
5. How to reading battery voltage and percentage, this is the sample code, you can modify it by your request.
sudo python3 x708bat.py
6. How to power off command on ubuntu from software
x708off * press button 1-2 seconds to reboot * press button 3 seconds to safe shutdown, * press 7-8 seconds to force shutdown.
7. Testing AC power off/loss or power adapter failure detection (need to shor the 'PLD' pin)
sudo python3 x708pld.py
8. Uninstall
./uninstall-ubuntu.sh
Return to X708
FAQ
Q1: Can't connect to pigpio at localhost(8888)
Can't connect to pigpio at localhost(8888) Did you start the pigpio daemon? E.g. sudo pigpiod Did you specify the correct Pi host/port in the environment variables PIGPIO_ADDR/PIGPIO_PORT? E.g. export PIGPIO_ADDR=soft, export PIGPIO_PORT=8888 Did you specify the correct Pi host/port in the pigpio.pi() function? E.g. pigpio.pi('soft', 8888) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Traceback (most recent call last): File "/home/volumio/x-c1/fan.py", line 8, in <module> pwm.set_mode(servo, pigpio.OUTPUT) File "/usr/lib/python2.7/dist-packages/pigpio.py", line 1376, in set_mode return _u2i(_pigpio_command(self.sl, _PI_CMD_MODES, gpio, mode)) File "/usr/lib/python2.7/dist-packages/pigpio.py", line 1025, in _pigpio_command sl.s.send(struct.pack('IIII', cmd, p1, p2, 0)) AttributeError: 'NoneType' object has no attribute 'send'
A: If you find an error similar to the above, it is because pigpiod library is not started, we need to run pigpiod first,
sudo pigpiod python 'your directory'/x-c1/fan.py &
If 'sudo' command request a password, you can use the following command:
echo 'your password' | sudo -S pigpiod python 'your directory'/x-c1/fan.py &
You can put these two lines in the /etc/rc.local file so that it will run automatically after booting.
Enable comment auto-refresher
Anonymous user #32
Permalink |
Anonymous user #20
Permalink |
Anonymous user #30
Permalink |
Anonymous user #31
Anonymous user #29
Permalink |
Lisa
Anonymous user #28
Permalink |
Cindy
Anonymous user #28
Anonymous user #27
Permalink |
Lisa
Anonymous user #26
Permalink |
Anonymous user #25
Permalink |
Anonymous user #25
Permalink |
Anonymous user #23
Permalink |
Lisa
Anonymous user #24
Anonymous user #22
Permalink |
Lisa
Anonymous user #20
Permalink |
Anonymous user #20
Anonymous user #20
Permalink |
Anonymous user #21
Anonymous user #19
Permalink |
Anonymous user #18
Permalink |
Lisa
Anonymous user #17
Permalink |
Anonymous user #16
Permalink |
Lisa
Anonymous user #15
Permalink |
Lisa
Anonymous user #14
Permalink |
Harry
Harry
Anonymous user #11
Permalink |
Anonymous user #12
Anonymous user #11
Permalink |
Anonymous user #10
Permalink |
Anonymous user #13
Anonymous user #13
Anonymous user #9
Permalink |
Lisa
Anonymous user #9
Permalink |
Harry
Anonymous user #8
Permalink |
Lisa
Anonymous user #7
Permalink |
Lisa
Anonymous user #6
Permalink |
Lisa
Anonymous user #5
Permalink |
Lisa
Anonymous user #4
Permalink |
Xiali
Anonymous user #3
Permalink |
Anonymous user #3
Xiali
Harry
Permalink |
Georgefeichter
Permalink |
Georgefeichter
Permalink |
Anonymous user #1
Permalink |
Anonymous user #2