Changes

Jump to navigation Jump to search

X708-script

1,744 bytes added, 20:09, 24 July 2023
cd ~x708-script
sudo python3 sample/plsd.py
 
'''fan.py''': Provides a method that can switch the fan 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 fan.py 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, please ignore this step. Because the X708 fan will run at low speed by default, this cooling capacity is sufficient.
* If you have full control over the runing of the fan, you need to run 'python3 /home/pi/x708v2/raspberry-pi-os/fan.py', and you need to create a crontab job also, and then put this run command ('@reboot python3 /home/XX/x708v2/raspberry-pi-os/fan.py 'XX' is your username, you need replace it with your username.') into the job, so that the command will run automatically when the device restarts. refer to [[X708-Software#FAQ]]
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.

Navigation menu