• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Temperature regulated fan on RPI

Scheduled Pinned Locked Moved Troubleshooting
3 Posts 3 Posters 1.8k Views 2 Watching
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 Offline
    Peter
    last edited by Feb 3, 2018, 11:16 AM

    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 Offline
      MadScientist
      last edited by MadScientist Feb 3, 2018, 11:46 AM Feb 3, 2018, 11:45 AM

      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
      • C Offline
        cruunnerr
        last edited by Feb 3, 2018, 11:58 AM

        @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
        1 / 1
        • First post
          1/3
          Last post
        Enjoying MagicMirror? Please consider a donation!
        MagicMirror created by Michael Teeuw.
        Forum managed by Sam, technical setup by Karsten.
        This forum is using NodeBB as its core | Contributors
        Contact | Privacy Policy