nope I do not use it
Slow CPU fan speed
Sorry I do not understand what I need to put into fan.py
use this as fan.py
find log in /var/log/fan.log
be not surprised when it is hourly cleared to 0 by cron
#!/usr/bin/env python3
import re
import time
import misc
import syslog
import pigpio # pylint: disable=import-error
from pathlib import Path
import logging
logging.basicConfig(filename='/var/log/fan.log', level=logging.INFO, format='%(asctime)s %(message)s', datefmt='%d.%m.%Y %H:%M:%S')
pattern = re.compile(r't=(\d+)\n$')
class MockPigpio:
@classmethod
def pi(cls):
try:
host = misc.check_output("netstat -l | grep -o '\S*:8888' | tr -d ':8888'")
gpio = pigpio.pi(host=host)
except Exception:
gpio = cls()
return gpio
def __init__(self):
syslog.syslog('PWM of pigpio is not available. Use on/off to control the fan.')
syslog.syslog('If you use pre-release kernel, please go back to stable release.')
def hardware_PWM(self, pin, _, dc):
misc.set_mode(pin, bool(dc))
gpio = MockPigpio.pi()
# t1: sensor_temp, t2: cpu_temp
def read_temp(cache={}):
w1_slave = cache.get('w1_slave')
if not w1_slave:
try:
w1_slave = next(Path('/sys/bus/w1/devices/').glob('28*/w1_slave'))
except Exception:
w1_slave = 'not exist'
cache['w1_slave'] = w1_slave
if w1_slave == 'not exist':
t1 = 42
else:
with open(w1_slave) as f:
t1 = int(pattern.search(f.read()).groups()[0]) / 1000.0
with open('/sys/class/thermal/thermal_zone0/temp') as f:
t2 = int(f.read().strip()) / 1000.0
logging.info('cpu: ' + str(t2) + ', hdd: '+str(t1 - 20))
return max(t1, t2)
# return t1
def turn_off():
misc.conf['run'].value = 0
gpio.hardware_PWM(12, 0, 0)
gpio.hardware_PWM(13, 0, 0)
def get_dc(cache={}):
if not(misc.conf['run'].value):
return 0
if time.time() - cache.get('time', 0) > 60:
cache['time'] = time.time()
cache['dc'] = misc.fan_temp2dc(read_temp())
return cache['dc']
def change_dc(dc, cache={}):
if dc != cache.get('dc'):
cache['dc'] = dc
gpio.hardware_PWM(12, 25000, dc * 10000)
gpio.hardware_PWM(13, 25000, dc * 10000)
logging.info('TEST'+str(dc*1))
def running():
while True:
change_dc(get_dc())
time.sleep(0.1)
Soo
I tried it with newest image of DietPi 7.8.2 with ARMv8 and this is my findings.
/etc/rockpi-sata.conf has these values
lv0 = 35
lv1 = 40
lv2 = 45
lv3 = 50
and there is output from log
21.11.2021 18:40:22 cpu: 10.0, hdd: 22
21.11.2021 18:40:22 TEST50
21.11.2021 18:41:22 cpu: 10.0, hdd: 22
21.11.2021 18:42:22 cpu: 40.0, hdd: 22
21.11.2021 18:43:22 cpu: 40.0, hdd: 22
21.11.2021 18:44:22 cpu: 50.0, hdd: 22
21.11.2021 18:44:22 TEST100
21.11.2021 18:45:22 cpu: 20.0, hdd: 22
21.11.2021 18:45:22 TEST50
21.11.2021 18:46:22 cpu: 46.0, hdd: 22
21.11.2021 18:46:22 TEST75
21.11.2021 18:47:22 cpu: 1.0, hdd: 22
21.11.2021 18:47:22 TEST50
So it looks like it can not run under 50% only for 50, 75 or 100%
But in 100% for me is slow I can’t feel fresh wind behind the fan.
I have old fan from RPi3 but it hasn’t PWM it is much faster and make much more noise but it not interested me because it is in garage