Skip to content

Instantly share code, notes, and snippets.

@louis-e
Last active August 18, 2019 15:34
Show Gist options
  • Save louis-e/7e814ffb3befd07eb9dc617b1bf13deb to your computer and use it in GitHub Desktop.
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.
#!/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