SHARE
TWEET

watch_temp on raspberry pi

DeaD_EyE Mar 19th, 2019 18 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python3
  2. import time
  3. from pathlib import Path
  4. import os
  5.  
  6.  
  7. temp_file = Path('/sys/class/thermal/thermal_zone0/temp')
  8. while True:
  9.     time.sleep(0.1)
  10.     temp = int(temp_file.read_text()) / 1000
  11.     x, y = os.get_terminal_size()
  12.     temp = '{:.1f} °C'.format(temp)
  13.     y //= 2
  14.     print('\033[2J\033[H')
  15.     print('\n' * y, end='')
  16.     print(str(temp).center(x))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top