Open main menu

Changes

X708-script

2,059 bytes added, 25 March
-->
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==
* Raspbian'''Raspberry Pi OS'''
* DietPi
* Manjaro
* RetroPie
* Twister
 
==Install==
Please follow the steps below:
#36 - the address of the battery fuel gauging chip
</PRE>
 
===Install gpiod package===
sudo apt install -y gpiod
===Clone the 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 ./x708-pwrxPWR.sh /usr/local/bin/sudo cp -f x708-pwr.service /lib/systemd/system
sudo systemctl daemon-reload
sudo systemctl enable x708-pwr
===Prepair software shutdown script===
sudo cp -f ./x708-softsdxSoft.sh /usr/local/bin/x708-softsd.shCreate Then create a alias <code>x708off</code> command to execute the software shutdown
<pre>
echo "alias x708off='sudo /usr/local/bin/x708-softsdxSoft.sh0 13'" >> ~/.bashrc
source ~/.bashrc
</pre>
'''PS:'''
 
Then you can run <code>x708off</code> to execute software shutdown as follows
x708off
'''x708-bat.py''': Script to read battery power and voltage;
cd ~x708-script
sudo python3 sample/x708-bat.py
'''x708-pld.py''': Script to AC Power supply loss dection
cd ~x708-script
sudo python3 sample/x708-pld.py
'''x708-plsd.py''': Script to AC Power supply loss dectionthen 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.pyThen 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-plsd11">#!/usr/bin/env python3 import subprocessimport 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.
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 [[x708X708-hardwareHardware#Pins_and_GPIO_used |x708 hardwarX708-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==
==Other resource==
* 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]* [[X728-Software]]
Return to [[X708]] or [[X708-hardwareHardware]]