This small Python script will display any temperature throttling messages on the Raspberry Pi.
Last active
November 7, 2020 19:45
-
-
Save lbussy/a77c002414b8759b8d822243052c3c3d to your computer and use it in GitHub Desktop.
Check Temp Throttling on RPi
This file contains 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 subprocess | |
GET_THROTTLED_CMD = 'vcgencmd get_throttled' | |
MESSAGES = { | |
0: 'Under-voltage detected.', | |
1: 'ARM frequency capped.', | |
2: 'Currently throttled.', | |
3: 'Soft temperature limit active.', | |
16: 'Under-voltage has occurred since last reboot.', | |
17: 'Throttling has occurred since last reboot.', | |
18: 'ARM frequency capped has occurred since last reboot.', | |
19: 'Soft temperature limit has occurred.' | |
} | |
print("Checking for throttling issues since last reboot.") | |
throttled_output = subprocess.check_output(GET_THROTTLED_CMD, shell=True) | |
throttled_binary = bin(int(throttled_output.split('=')[1], 0)) | |
warnings = 0 | |
for position, message in MESSAGES.iteritems(): | |
# Check for the binary digits to be "on" for each warning message | |
if len(throttled_binary) > position and throttled_binary[0 - position - 1] == '1': | |
print(message) | |
warnings += 1 | |
if warnings == 0: | |
print("Look good.") | |
else: | |
print("There may be a problem.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment