Skip to content

Instantly share code, notes, and snippets.

@louis-e
Last active August 18, 2019 15:34
Embed
What would you like to do?
A python script to protect raspberry pi against overheating because of omxplayer.
#!/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