<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.geekworm.com/index.php?action=history&amp;feed=atom&amp;title=CommentStreams%3A11e8ae6c4c76e6356e45a1e779a977bd</id>
	<title>CommentStreams:11e8ae6c4c76e6356e45a1e779a977bd - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.geekworm.com/index.php?action=history&amp;feed=atom&amp;title=CommentStreams%3A11e8ae6c4c76e6356e45a1e779a977bd"/>
	<link rel="alternate" type="text/html" href="https://wiki.geekworm.com/index.php?title=CommentStreams:11e8ae6c4c76e6356e45a1e779a977bd&amp;action=history"/>
	<updated>2026-07-27T06:47:15Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://wiki.geekworm.com/index.php?title=CommentStreams:11e8ae6c4c76e6356e45a1e779a977bd&amp;diff=33537&amp;oldid=prev</id>
		<title>83.239.24.170: Migrated reply #4047</title>
		<link rel="alternate" type="text/html" href="https://wiki.geekworm.com/index.php?title=CommentStreams:11e8ae6c4c76e6356e45a1e779a977bd&amp;diff=33537&amp;oldid=prev"/>
		<updated>2023-10-06T16:53:22Z</updated>

		<summary type="html">&lt;p&gt;Migrated reply #4047&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;small refactoring of fan-rpi.py&lt;br /&gt;
&lt;br /&gt;
#!/usr/bin/python3&lt;br /&gt;
&lt;br /&gt;
# DON&amp;#039;T use pigpiod library on Nov. 24 2022 by Harry Huang&lt;br /&gt;
#import pigpio&lt;br /&gt;
import RPi.GPIO as IO&lt;br /&gt;
import time&lt;br /&gt;
import subprocess&lt;br /&gt;
import logging&lt;br /&gt;
&lt;br /&gt;
servo = 18&lt;br /&gt;
logging.basicConfig(format=&amp;#039;%(message)s&amp;#039;, level=logging.DEBUG)&lt;br /&gt;
IO.setwarnings(False)&lt;br /&gt;
IO.setmode (IO.BCM)&lt;br /&gt;
IO.setup(servo,IO.OUT)&lt;br /&gt;
fan = IO.PWM(servo,2000)&lt;br /&gt;
fan.start(0)&lt;br /&gt;
&lt;br /&gt;
def get_temp():&lt;br /&gt;
    output = subprocess.run([&amp;#039;cat&amp;#039;, &amp;#039;/sys/class/thermal/thermal_zone0/temp&amp;#039;], capture_output=True)&lt;br /&gt;
    temp_str = output.stdout.decode()&lt;br /&gt;
    try:&lt;br /&gt;
        return float(temp_str)/1000&lt;br /&gt;
    except (IndexError, ValueError):&lt;br /&gt;
        raise RuntimeError(&amp;#039;Could not get temperature&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
while 1:&lt;br /&gt;
    temp = get_temp()                        # Get the current CPU temperature&lt;br /&gt;
    if temp &amp;gt; 60:                            # Check temperature threshhold, in degrees celcius&lt;br /&gt;
        fan.ChangeDutyCycle(100)             # Set fan duty based on temperature, 100 is max speed and 0 is min speed or off.&lt;br /&gt;
        logging.debug(&amp;quot;Temp: %d, speed: 100&amp;quot;, temp)&lt;br /&gt;
    elif temp &amp;gt; 50:&lt;br /&gt;
        fan.ChangeDutyCycle(90)&lt;br /&gt;
        logging.debug(&amp;quot;Temp: %d, speed: 90&amp;quot;, temp)&lt;br /&gt;
    elif temp &amp;gt; 40:&lt;br /&gt;
        fan.ChangeDutyCycle(85)&lt;br /&gt;
        logging.debug(&amp;quot;Temp: %d, speed: 85&amp;quot;, temp)&lt;br /&gt;
    elif temp &amp;gt; 32:&lt;br /&gt;
        fan.ChangeDutyCycle(70)&lt;br /&gt;
        logging.debug(&amp;quot;Temp: %d, speed: 70&amp;quot;, temp)&lt;br /&gt;
    elif temp &amp;gt; 25:&lt;br /&gt;
        fan.ChangeDutyCycle(60)&lt;br /&gt;
        logging.debug(&amp;quot;Temp: %d, speed: 60&amp;quot;, temp)&lt;br /&gt;
    else:&lt;br /&gt;
        fan.ChangeDutyCycle(0)&lt;br /&gt;
        logging.debug(&amp;quot;Temp: %d, speed: 0&amp;quot;, temp)&lt;br /&gt;
    time.sleep(5)                            # Sleep for 5 seconds&amp;lt;!-- migrated from Comments; original IP: 83.239.24.170 --&amp;gt;&lt;/div&gt;</summary>
		<author><name>83.239.24.170</name></author>
	</entry>
</feed>