MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord
    MagicMirror² v2.20.0 is available! For more information about this release, check out this topic.

    Temperature regulated fan on RPI

    Troubleshooting
    3
    3
    1439
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      Peter last edited by

      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

      1 Reply Last reply Reply Quote 0
      • M
        MadScientist last edited by MadScientist

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

        1 Reply Last reply Reply Quote 0
        • cruunnerr
          cruunnerr last edited by

          @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()
          
          1 Reply Last reply Reply Quote 1
          • 1 / 1
          • First post
            Last post
          Enjoying MagicMirror? Please consider a donation!
          MagicMirror created by Michael Teeuw.
          Forum managed by Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
          This forum is using NodeBB as its core | Contributors
          Contact | Privacy Policy