1
0
mirror of https://github.com/MarkParker5/STARK.git synced 2024-11-24 08:12:13 +02:00
STARK/pi_temp.py

23 lines
461 B
Python
Raw Normal View History

2020-10-30 22:25:25 +02:00
import os
import time
import RPi.GPIO as GPIO
pin = 3
2020-10-31 12:04:13 +02:00
cooling = False
2020-10-30 22:25:25 +02:00
def current_temp():
temp = os.popen("vcgencmd measure_temp").readline()
return temp.replace("temp=","")
2020-10-31 12:04:13 +02:00
GPIO.setmode(GPIO.BCM)
2020-10-30 22:25:25 +02:00
GPIO.setup(pin, GPIO.OUT)
while True:
2020-10-31 12:04:13 +02:00
temp = float(current_temp()[:4])
2020-10-30 22:25:25 +02:00
if temp > 55:
cooling = True
elif temp < 40:
cooling = False
GPIO.output(pin, cooling)
print(f'temp={temp}, cooling={cooling}')
time.sleep(1)