树莓派温控风扇

#coding=utf-8
#!/usr/bin/python
import sys
import time
try:
	import RPi.GPIO as GPIO
except RuntimeError:
    print("Error importing RPi.GPIO!  This is probably because you need superuser privileges.  You can achieve this by using 'sudo' to run your script")
def cpu_temp():
    with open("/sys/class/thermal/thermal_zone0/temp", 'r') as f:
        return float(f.read())/1000
def main():
    # Simplex use BCM-->4 pin control the fan 
    channel = 4
    # Duplex use BCM-->17 pin control the fan
    #channel = 17

# GPIO.setmode(GPIO.BOARD)#也许使用扩展board导致标注的数字是BCM的,猜测而已。
    GPIO.setmode(GPIO.BCM)
    GPIO.setwarnings(False)
    # close air fan first
    GPIO.setup(channel, GPIO.OUT, initial=GPIO.LOW)
    is_close = True
    while True:
        temp = cpu_temp()
        if is_close:
            if temp > 49.0:
                print time.ctime(), temp, '℃ open air fan'
                GPIO.output(channel, 1)
                is_close = False
        else:
            if temp < 47.0:
                print time.ctime(), temp, '℃ close air fan'
                GPIO.output(channel, 0)
                is_close = True
        time.sleep(2.0)
        print time.ctime(), temp, '℃'
if __name__ == '__main__':
    main()

https://blog.csdn.net/brucewata/article/details/88076312

https://www.jianshu.com/p/20fea50cf483

设置代理上网

cd /etc/apt/apt.conf.d

  • 新建一个名为10proxy的文件

sudo nano 10proxy

  • 编辑其中内容

sudo nano /etc/apt/apt.conf.d/10proxy

  • 如果不需要认证,以下格式即可

Acquire::http::Proxy “http://web-proxy.corp.xx.com:8080”;

  • 如果需要认证,按照以下格式

Acquire::http::Proxy “http://username:password@yourproxyaddress:proxyport/”;

Ctrl + X确认并保存,然后查看树莓派是否可以在代理下上网