8,803 bytes added,
14:25, 25 March 2024 {{GD Template Impl}}
==Overview==
This is script installation tutorial for [[X708]] shield, it will replace [[X708-Software | X708 Software installation tutorial]], although [[X708-Software | X708 Software installation tutorial]] is still available, but we strongly recommend that you use this script tutorial, which simplifies the installation process and reduces dependencies on third-party python libraries.
<!--
The core shell script of [[X708-script]] comes from from [https://github.com/pimlie/geekworm-x-c1 pimlie/geekworm-x-c1], pimlie implements the pwm fan shell script, which does not depend on third-party python libraries at all. Thanks to pimlie.
-->
Now we think you have successfully flashed the OS Image into Micro SD and and power on the device, and you have also completed the operations such as creating new user required in some OS. You need to perform the following operations in <code>Terminal</code>.
'''[NOTE]:'''
1. The script now supports the Raspberry Pi OS '''BOOKWORM''' version. You just need to '''uninstall''' the original script and '''reinstall''' it. Please refer to the following:
OPen ternimal window, then run the following command:
<pre>
mv x708-script x708-script-old
git clone https://github.com/geekworm-com/x708-script
cd x708-script
chmod +x *.sh
./uninstall.sh
</pre>
Then just follow the installation process below.
==OS that has been tested==
* '''Raspberry Pi OS'''
* DietPi
* Manjaro
* Ubuntu
* myNode
* Umbrel
* Volumio
* RetroPie
* Twister
==Install==
Please follow the steps below:
===Enable I2C===
Reter to [[How to enable I2C]]
NOTE: sample/x708-v2.x-bat.py or sample/x708-v1.x-bat will run with error if you don't enable I2C.
'''Check & review I2C address:'''
<PRE>
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 -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
</PRE>
Explaination:
<PRE>
#36 - the address of the battery fuel gauging chip
</PRE>
===Install gpiod package===
sudo apt install -y gpiod
===Clone the script===
<pre>
git clone https://github.com/geekworm-com/x708-script
cd x708-script
chmod +x *.sh
</pre>
'''PS''': For some OS such as 'Raspberry Pi OS Lite', the '''git''' tool is not installed by default, if you get an error like '''error: -bash: git: command not found''', please run the following command to install the git tool.
sudo apt install -y git
===Create the x708-pwr service===
x708-pwr service will be responsible for power management and hardware safe shutdown.
<pre>
sudo cp -f ./xPWR.sh /usr/local/bin/
sudo cp -f x708-pwr.service /lib/systemd/system
sudo systemctl daemon-reload
sudo systemctl enable x708-pwr
sudo systemctl start x708-pwr
</pre>
Now, if you press and hold the onboard switch for 3 seconds, then the blue LED will flash slowly and the shutdown is going then all LEDs will be off until the device is completely powered off.
===Prepair software shutdown script===
sudo cp -f ./xSoft.sh /usr/local/bin/
Then create a alias <code>x708off</code> command to execute the software shutdown
<pre>
echo "alias x708off='sudo /usr/local/bin/xSoft.sh 0 13'" >> ~/.bashrc
source ~/.bashrc
</pre>
'''PS:'''
Then you can run <code>x708off</code> to execute software shutdown as follows
x708off
===Test safe shutdown===
'''Software safe shutdown command''':
x708off
<span class="tb_red">DON'T run the 'shutdown' linux command to shut down, otherwise the power of x708 shield will not be shut down.</span>
'''Hardware safe shutdown operation''':
You can verify the safety switch through the onboard switch, press and hold the switch for <code>3</code> seconds, then the blue LED will flash slowly and the shutdown is going then all LEDs will be off until the device is completely powered off.
* press on-board button switch <code>1-2</code> seconds to reboot
* press button switch <code>3</code> seconds to safe shutdown,
* press <code>7-8</code> seconds to force shutdown.
===Sample Files===
The example programs are only suitable for advanced players, and you can construct your own usage scenarios according to the example programs.
Each example program demonstrates a different function:
'''x708-bat.py''': Script to read battery power and voltage;
cd ~x708-script
sudo python3 sample/bat.py
'''x708-pld.py''': Script to AC Power supply loss dection
cd ~x708-script
sudo python3 sample/pld.py
'''x708-plsd.py''': Script to AC Power supply loss dection then safe shutdown
cd ~x708-script
sudo python3 sample/plsd.py
'''fan.py''': Provides a method that can switch the fan speed.
sudo python3 sample/fan.py
Then the fan will run with high speed.
<blockquote>
It should be noted that the x708 '''DOES NOT''' use a PWM fan, it only supports two speed modes (low speed and high speed). In the <code>fan.py</code> file, the speed mode of the fan is controlled by reading the temperature of the CPU in real time. You need to read the fan.py code to understand more logic.
You can control the fan running at high speed or low speed via modify the CPU temperature threshold in <code>fan.py</code> script file (yellow highlight line)
</blockquote>
<syntaxhighlight lang="python" line highlight="9-11">
#!/usr/bin/env python3
import subprocess
import time
from gpiozero import OutputDevice
ON_THRESHOLD = 55 # (degrees Celsius) Fan running at high speed at this temperature.
OFF_THRESHOLD = 50 # (degress Celsius) Fan running at low speed at this temperature.
SLEEP_INTERVAL = 5 # (seconds) How often we check the core temperature.
GPIO_PIN = 16 # Which GPIO pin you're using to control the fan. DON'T change it!
def get_temp():
"""Get the core temperature.
Run a shell script to get the core temp and parse the output.
</syntaxhighlight>
'''[PS]''': If you can't understand <code>fan.py</code>, please ignore this step. Because the X708 fan will run at low speed by default, this cooling capacity is sufficient.
1. Al sample python files maybe depends on the third-party python library `Rpi.GPIO`. In the official Raspberry Pi OS and most third-party OS, this library is installed by default. If you run this file and get some errors, try to run the following command to install the Rpi.GPIOy library.
sudo apt-get install -y python3-smbus python3-rpi.gpio
Or you can refer to [[How to Install RPi.GPIO Python Library]]
2. The sample file based on the version number is just because different versions of x708 shield use different GPIOs, they are basically the same. You can use a file comparison tool to view it, if you get it wrong, most likely you are using the wrong version of the sample file. You can refer to [[X708-Hardware#Pins_and_GPIO_used |X708-Hardware]] to check the PIN occupancy of x708 shield.
3. The sample program is only to demonstrate how to use the advanced functions of the shield, we do not provide the development function of the sample program.
==Support==
Email: support@geekworm.com
==FAQ==
<html>
<details>
<summary>Q: How to login <b>volumio</b> via SSH?</summary>
<p>1. Enable SSH:</p>
<p>Visit http://volumio.local/dev/, then click <b>ENABLE SSH</b> button</p>
<p>2. URL connection is IP address, and the default user name is <b>volumio</b>, default password is <b>volumio</b></p>
</details>
<details>
<summary>Q: How to login to <b>Umbrel</b> via SSH?</summary>
A: ssh umbrel@umbrel.local (or ssh umbrel@<IP address of your Umbrel>). the default user name is <b>umbrel</b>, default password is <b>moneyprintergobrrr</b>
</details>
<details>
<summary>Q: How to login to <b>myNode</b> via SSH?</summary>
A: URL connection is IP address, and the default user name is <b>admin</b>, default password is <b>bolt</b>
</details>
<details>
<summary>Q: How to login to <b>DietPi</b> via SSH?</summary>
A: URL connection is IP address, and the default user name is <b>root</b>, default password is <b>dietpi</b>
</details>
<details>
<summary>Q: Is <b>LibreELEC</b> supported?</summary>
A: TODO
</details>
</html>
==Other resource==
* Chip-Specifications:[[File:MAX17040-MAX17041.pdf]]
* [https://www.instructables.com/Raspberry-Pi-Tutorial-How-to-Use-a-Buzzer/ Raspberry Pi Tutorial: How to Use a Buzzer]
* [[X728-Software]]
Return to [[X708]] or [[X708-Hardware]]
<!--Add review function! -->
<comments />
<!--Please choose the -->
<!--Remove other categories, just keep the appropriate categories -->
[[Category:Product Manual]]
[[Category:Raspberry pi]]
[[Category:Knowledge]]