Last active
August 18, 2019 15:34
-
-
Save louis-e/7e814ffb3befd07eb9dc617b1bf13deb to your computer and use it in GitHub Desktop.
A python script to protect raspberry pi against overheating because of omxplayer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import os | |
import time | |
def measure_temp(): | |
temp = os.popen("vcgencmd measure_temp").readline() | |
return (temp.replace("temp=","").replace("'C","")) | |
while True: | |
temp = measure_temp() | |
print(temp) | |
if temp > '83': | |
print("TEMPCONTROL.PY:quitted_omxplayer_because_of_overheat") | |
os.system('sudo python /home/pi/omxcontrol/examples/omxcommand.py q') | |
elif temp > '86': | |
print("TEMPCONTROL.PY:shutting_down_because_of_oveaheat") | |
os.system("sudo shutdown -h now") | |
time.sleep(7) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment