-

CommentStreams:1a3077734abfef1a718d3faed6850d43

From Geekworm Wiki
< X715 Software
Revision as of 05:12, 8 December 2023 by 50.4.166.201 (talk) (Migrated comment #4177)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Seems to work with this code:

  1. !/usr/bin/python

from gpiozero import PWMLED import time

try:

    servo = 13
    fan = PWMLED(servo)
    while(1):
         #get CPU temp
         file = open("/sys/class/thermal/thermal_zone0/temp")
         temp = float(file.read()) / 1000.00
         temp = float('%.2f' % temp)
         file.close()
         if(temp > 35):
              fan.value = 0.4
         if(temp > 40):
              fan.value = 0.5
         if(temp > 50):
              fan.value = 0.75
         if(temp > 55):
              fan.value = 0.9
         if(temp > 60):
              fan.value = 1.0
         if(temp < 30):
              fan.off()
         time.sleep(1)

except KeyboardInterrupt:

   fan.off()