You are not logged in.
Ok, so given my experience I might have been better off placing this in the newbie section. However, I am fairly confident that by the possible level of complexity I might be better off here. I am just hoping for someone knowledgeable to co-tackle this problem with me.
The situation: I have recently installed Arch on an old HP-Mini notebook. It is amazingly fast (so happy faces), but unfortunately the laptops cooling system is driving me nuts. It keeps on swinging between full-on and full-off like constantly.
So, I have been looking into fan-control. lm_sensors seemed a dead-end as it detected pretty much nothing and I ended up focusing on acpi.
One of the most helpful pages I managed to find was this one https://bbs.archlinux.org/viewtopic.php?id=186684.
I followed the steps to create my own version of fancontrol.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time, os, sys, signal, setproctitle, traceback
MIN_TEMP = 70 # fan starts to cool
MAX_TEMP = 95 # fan cooling full power
def call_acpi(command):
acpi_call = open('/proc/acpi/call', 'w')
acpi_call.write(command)
acpi_call.close()
# Response
acpi_call = open('/proc/acpi/call')
response = acpi_call.read()
acpi_call.close()
return response
def set_fan(speed, fan=1):
if speed < 0:
speed = 0
elif speed > 100:
speed = 100
raw_speed = round(speed * 2.55)
call_acpi('\_SB.PCI0.LPC.CMEC.SFAN %d %s' % (fan, raw_speed))
print('Set fan speed to %d %%' % speed)
def get_cpu_temp():
print("test")
print("tmp1 =", (int(call_acpi('\_SB.PCI0.LPC.CMEC.FSPH')[:4], 16)))
print("tmp2 =", (int(call_acpi('\_SB.PCI0.LPC.CMEC.FSPL')[:4], 16)))
return int(call_acpi('\_SB.PCI0.LPC.CMEC.FSPH')[:4], 16)
#return int(call_acpi('\_SB.PCI0.LPC.CMEC.FSPL')[:4], 16)
print("tmp1 =", (int(call_acpi('\_SB.PCI0.LPC.CMEC.FSPH')[:4], 16)))
#print("tmp2 =", (int(call_acpi('\_SB.PCI0.LPC.CMEC.FSPL')[:4], 16)))
# you can adjust the fan behavior with any mathematic function
# for example you can use a square function "return temp**2* or cubic "return temp**3"
def scale_temp(temp):
return temp
def handle_fan(current_temp):
temp_range = MAX_TEMP - MIN_TEMP
norm_temp = current_temp - MIN_TEMP if (current_temp - MIN_TEMP) > 0 else 0
scaled_temp = scale_temp(norm_temp)
scaled_border = scale_temp(temp_range)
fan_speed = 100/scaled_border * scaled_temp # in percent
print("Current CPU temperature %d°" % current_temp)
set_fan(fan_speed)
def cleanup(signal=None, frame=None):
call_acpi('\_SB.PCI0.LPC.CMEC.FSPH 0 0')
call_acpi('\_SB.ATKD.QMOD 0x02')
print('\nReset fan control to automatic. Exiting...')
sys.exit(0)
def main():
signal.signal(signal.SIGTERM, cleanup)
try:
while True:
handle_fan(get_cpu_temp())
time.sleep(2)
except:
traceback.print_exc()
finally:
cleanup()
if __name__=='__main__':
# TODO: only one instance
setproctitle.setproctitle('fancontrol')
main()
Ok, so far so good. I am not sure wether the script is actually doing what it is supposed to but I do think that I have found the culprit of my problems. As the output read:
test
tmp1 = 20
tmp2 = 26
Current CPU temperature 20°
Set fan speed to 0 %
test
tmp1 = 19
tmp2 = 150
Current CPU temperature 19°
Set fan speed to 0 %
test
tmp1 = 20
tmp2 = 204
Current CPU temperature 20°
Set fan speed to 0 %
test
tmp1 = 20
tmp2 = 100
Current CPU temperature 20°
Set fan speed to 0 %
test
tmp1 = 20
tmp2 = 15
As you can see, with a 2 second interval the second sensor is showing major rises and drops in temperature.
I am hoping there might be a simple 'cheat-fix', like simply telling my fans to completely ignore the readings of that sensor. My worst fear is that this might be an unsolvable hardware-solution. Everything in between; well, I'm up for it.
I could post many different outputs that I've produced in my efforts to stop this problem, but in an effort to avoid cluttering the screen and raising more questions then clarity; just let me know what output(s) to post and I'll try to post them asap.
Thanks in advance. NS
Last edited by NewS (2016-11-09 20:23:43)
"Stay hungry - Stay foolish"
Offline