DeaD_EyE

watch_temp on raspberry pi

Mar 19th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  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))
Add Comment
Please, Sign In to add comment