Controlling the fan speed and detecting the inside temperature of the pc with python?

后端 未结 3 398
失恋的感觉
失恋的感觉 2021-01-18 08:15

Since my pc\'s fan is very loud, I\'d like to make myself a program to \"shut it up\" when it\'s not required to be running at full speed. I want to make it with python, so

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-18 08:58

    I have found something that at least can be interesting. It does not control de fan "direclty" it controls de CPU Temperature to that the fan depends to. I use it for cleaning purposes. I just run this code, and with air dust cleaner it is possible to clean the fan.

    import multiprocessing
    
    def worker():
        """worker function"""
        print ('Worker')
        k = []
    
        # of course in an infinite loop
        while True:
            # lets use the cpu mathematical power, to increse its temp
            l = (2*33) >> 3 
            # it is also possible to consume memory..
            # but it will crash windows 8.1 after a while
            # k.append(l)
            pass
        return
    
    if __name__ == '__main__':
        jobs = []
    
        cpu = multiprocessing.cpu_count()
        print("CPU count=" + str(cpu))
        for i in range(cpu):
            p = multiprocessing.Process(target=worker)
            jobs.append(p)
            p.start()
    

    But, do not uncomment the memory part, it will crash your PC. This is using python 3.5 version on an i7 8core logical cpu PC

提交回复
热议问题