防烤糊必备

import os
import time
from pyA20.gpio import gpio
from pyA20.gpio import port
#GPIO:https://github.com/duxingkei33/orangepi_PC_gpio_pyH3
#适用于全H3系列和H2+
Pin = port.PA10
gpio.init() #初始化
gpio.setcfg(Pin, gpio.OUTPUT) #输出
while 1:
    output = os.popen('cat /sys/devices/virtual/hwmon/hwmon1/temp1_input') 
    #读取温度,来自CPU的温度传感器
    #初版Zero由于基准电压的原因,可能偏高
    wd = output.read()
    print int(wd)
    if(int(wd)>50): #大于50度开启
        gpio.output(Pin, 1)
        time.sleep(1)
    if(int(wd)<50):
        gpio.output(Pin, 0)
        time.sleep(1)

标签: Orange Pi, Elec

添加新评论