Temperature regulated fan on RPI



  • I need some help (again).
    I made a temperature regulated fan following these instructions:
    https://www.npmjs.com/package/rpi-fan-controller
    It works fine, but the fan starts at the default 45 degrees celsius.
    I would like to change that to 55 or 60 degrees celcius.
    I tried several things, but no succes.
    Thanks foor any help.
    Peter



  • I think more information is needed. Did you run the script with sudo rpifan -t 55 or sudo rpifan --maxtemp 55?



  • @Peter

    why not just using a python script?

    found this one here:

    #!/usr/bin/env python3
    # coding: utf-8
    
    import os
    import time
    import signal
    import sys
    import RPi.GPIO as GPIO
    pin = 36 # The pin ID, edit here to change it
    maxTMP = 50 # The maximum temperature in Celsius after which we trigger the fan
    GPIO.setmode (GPIO.BOARD)
    
    def setup():
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(pin,GPIO.OUT)
        GPIO.setwarnings(False)
        return()
    def getCPUtemperature():
        res = os.popen('vcgencmd measure_temp').readline()
        temp =(res.replace("temp=","").replace("'C\n",""))
        print("temp is {0}".format(temp)) #Uncomment here for testing
        return temp
    def fanON():
        setPin(True)
        return()
    def fanOFF():
        setPin(False)
        return()
    def getTEMP():
        CPU_temp = float(getCPUtemperature())
    
        if CPU_temp>maxTMP:
            fanON()
    
        else:
            fanOFF()
    
        return()
    def setPin(mode): # A little redundant function but useful if you want to add logging
        GPIO.output(pin, mode)
        return()
    try:
        setup()
        while True:
            getTEMP()
            time. sleep(8) # Read the temperature every 5 sec, increase or decrease this limit if you want
    except KeyboardInterrupt: # trap a CTRL+C keyboard interrupt
    	GPIO.cleanup()