Python get cpu temp
8 Python code examples are found related to "
get cpu temp".
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: graph.py From displayotron with MIT License | 6 votes |
def get_cpu_temp(self): tempFile = open("/sys/class/thermal/thermal_zone0/temp") cpu_temp = tempFile.read() tempFile.close() return float(cpu_temp) / 1000
Example 2
Source File: weather_station.py From pi_weather_station with MIT License | 6 votes |
def get_cpu_temp(): # 'borrowed' from https://www.raspberrypi.org/forums/viewtopic.php?f=104&t=111457 # executes a command at the OS to pull in the CPU temperature res = os.popen('vcgencmd measure_temp').readline() return float(res.replace("temp=", "").replace("'C\n", "")) # use moving average to smooth readings
Example 3
Source File: main.py From SAKS-tutorials with GNU General Public License v2.0 | 5 votes |
def get_cpu_temp(): tempFile = open( "/sys/class/thermal/thermal_zone0/temp" ) cpu_temp = tempFile.read() tempFile.close() return float(cpu_temp)/1000 # Uncomment the next line if you want the temp in Fahrenheit #return float(1.8*cpu_temp)+32
Example 4
Source File: monitor.py From enviro-dashboard with MIT License | 5 votes |
def get_cpu_temp(): path="/sys/class/thermal/thermal_zone0/temp" f = open(path, "r") temp_raw = int(f.read().strip()) temp_cpu = float(temp_raw / 1000.0) return temp_cpu
Example 5
Source File: automatic.py From fanshim-python with MIT License | 5 votes |
def get_cpu_temp(): t = psutil.sensors_temperatures() for x in ['cpu-thermal', 'cpu_thermal']: if x in t: return t[x][0].current print("Warning: Unable to get CPU temperature!") return 0
Example 6
Source File: tbng.py From tbng with The Unlicense | 5 votes |
def get_cpu_temp(options): check_options(options,0) retval="Temperature monitoring not supported" if 'cputemp' in configuration: retval=run_plugin("cputemp",configuration['cputemp']) print("{0}".format(retval))
Example 7
Source File: lcd.py From bitnodes-hardware with MIT License | 4 votes |
def get_cpu_temp(): """ CPU temperature should be below 80C for normal operation. """ celcius = None temp = '/sys/devices/virtual/thermal/thermal_zone0/temp' if os.path.exists(temp): celcius = int(open(temp).read().strip()) / 1000 return celcius