Skip to content

Instantly share code, notes, and snippets.

@okalachev
Last active April 21, 2021 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save okalachev/364702ab3c4fb4152e9dcdd287e895d0 to your computer and use it in GitHub Desktop.
Save okalachev/364702ab3c4fb4152e9dcdd287e895d0 to your computer and use it in GitHub Desktop.
Script for plotting RPi temperature graph
# Running: PYTHONUNBUFFERED=1 python temp_plot.py | tee temp.csv
import time
import subprocess
print('uptime,temperature,throttling')
while True:
uptime = float(open('/proc/uptime', 'r').readline().split()[0]) / 60
temp = float(open('/sys/class/thermal/thermal_zone0/temp').read()) / 1000
throttled = subprocess.check_output(['vcgencmd', 'get_throttled'])
throttle_mask = int(throttled.split('=')[1], base=16)
print('%s,%s,%s' % (uptime, temp, throttle_mask))
time.sleep(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment