Raspberry Pi 5 上的风扇速度控制在 Ubuntu 23.10 中不起作用

Ste*_*gle 5 fan raspberrypi 23.10

在 Raspberry Pi 5 上运行 Ubuntu 23.10 时,风扇速度控制似乎不起作用。风扇始终以接近最大速度运行,并且无论 CPU 温度如何,cur_state风扇/sys/class/thermal/cooling_device0/都会停留在该值。4我怀疑它与 Raspberry Pi OS 上报告的此故障有关:https://forums.raspberrypi.com/viewtopic.php ?t=356881

其他人在这方面取得过成功吗?

小智 0

这很烦人,我一直在做的只是交换值,直到我们得到一个新的稳定内核:

sudo bash
cat > /sys/class/thermal/cooling_device0/cur_state
2
<CTRL-D>
Run Code Online (Sandbox Code Playgroud)


小智 0

我也对此感到恼火,决定让 Python 完成所有工作。\n随意使用此https://pastebin.com/SbFb4LYE

\n
from subprocess import run as srun, PIPE\nfrom time import sleep\nfrom datetime import timedelta as td, datetime as dt\n \n## Use step values to activate desired FAN value\nSTEP1 = 48\nSTEP2 = 60\nSTEP3 = 65\nSTEP4 = 72\n \nSLEEP_TIMER = 1\n \nTICKS = 3\nDELTA_TEMP = 3\nDATETIME_FORMAT = \'%Y-%m-%d %H:%M:%S\'\nfanControlFile = \'/sys/class/thermal/cooling_device0/cur_state\'\n \ndef main():\n    print("Running FAN control for RPI5 Ubuntu")\n    t0 = dt.now()\n \n    command = f\'tee -a {fanControlFile} > /dev/null\'\n    oldSpeed = 0\n    ticks = 0\n \n    speed = 1\n    lastTemp = 0\n \n    while True:\n        sleep(SLEEP_TIMER) # force 1 second timer, just to reduce polling calls\n        t1 = dt.now()\n        if(t1 + td(minutes=TICKS) > t0):\n            t0 = t1\n            \n            tempOut = getOutput(\'vcgencmd measure_temp\')\n            try:\n                cels = int(tempOut.split(\'temp=\')[1][:2])\n            except:\n                cels = 40\n \n            if STEP1 < cels < STEP2:\n                speed = 1\n            elif STEP2 < cels < STEP3:\n                speed = 2\n            elif STEP3 < cels < STEP4:\n                speed = 3\n            elif cels >= STEP4:\n                speed = 4\n \n            deltaTempNeg = lastTemp - DELTA_TEMP\n            deltaTempPos = lastTemp + DELTA_TEMP\n \n            if oldSpeed != speed and not(deltaTempNeg <= cels <= deltaTempPos):\n                print(f\'oldSpeed: {oldSpeed} | newSpeed: {speed}\')\n                print(f\'{deltaTempNeg}\xc2\xbaC <= {cels}\xc2\xbaC <= {deltaTempPos}\xc2\xbaC\')\n                print(f\'{"#"*30}\\n\' +\n                    f\'Updating fan speed!\\t{t0.strftime(DATETIME_FORMAT)}\\n\' +\n                    f\'CPU TEMP: {cels}\xc2\xbaC\\n\' +\n                    f\'FAN speed will be set to: {speed}\\n\' +\n                    f\'{"#"*30}\\n\')\n                \n                _command = f\'echo {speed} | sudo {command}\'\n                callShell(_command, debug=True)\n                checkVal = getOutput(f\'cat {fanControlFile}\')\n                print(f\'Confirm FAN set to speed: {checkVal}\')\n                \n                oldSpeed = speed\n                lastTemp = cels\n                ticks = 0\n            \n            # Log minor details\n            ticks += 1\n            if(ticks > TICKS * 3):\n                ticks = 0\n                print(f\'Current Temp is: {cels}\xc2\xbaC\\t{t0.strftime(DATETIME_FORMAT)}\')\n    \ndef callShell(cmd, shell=True, debug=False):\n    if debug:\n        print(f\'Calling: [{cmd}]\')\n    return srun(f\'\'\'{cmd}\'\'\', stdout=PIPE, shell=shell)\n \ndef getOutput(cmd, shell=True):\n    stdout = callShell(cmd, shell=shell).stdout\n \n    try:\n        stdout = stdout.decode(\'utf-8\')\n    except:\n        pass\n \n    return stdout\n \n## RUN SCRIPT\nmain()\n
Run Code Online (Sandbox Code Playgroud)\n