Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
print CPU temperature
#13
try psutil

import sys

import psutil


def main():
    if not hasattr(psutil, "sensors_temperatures"):
        sys.exit("platform not supported")
    temps = psutil.sensors_temperatures()
    if not temps:
        sys.exit("can't read any temperature")
    for name, entries in temps.items():
        print(name)
        for entry in entries:
            print("    %-20s %s °C (high = %s °C, critical = %s °C)" % (
                entry.label or name, entry.current, entry.high,
                entry.critical))
        print()


if __name__ == '__main__':
    main()
Output:
coretemp Package id 0 34.0 °C (high = 82.0 °C, critical = 102.0 °C) Core 0 31.0 °C (high = 82.0 °C, critical = 102.0 °C) Core 1 35.0 °C (high = 82.0 °C, critical = 102.0 °C) w83667hg AUXTIN 35.0 °C (high = -1.0 °C, critical = -1.0 °C) PECI Agent 1 31.0 °C (high = 0.0 °C, critical = None °C) SYSTIN 29.0 °C (high = 0.0 °C, critical = None °C)
Reply


Messages In This Thread
print CPU temperature - by samuelbachorik - Jul-29-2020, 06:23 PM
RE: print CPU temperature - by Axel_Erfurt - Jul-29-2020, 06:31 PM
RE: print CPU temperature - by samuelbachorik - Jul-29-2020, 06:34 PM
RE: print CPU temperature - by Axel_Erfurt - Jul-29-2020, 06:39 PM
RE: print CPU temperature - by j.crater - Jul-29-2020, 07:58 PM
RE: print CPU temperature - by Axel_Erfurt - Jul-29-2020, 08:03 PM
RE: print CPU temperature - by samuelbachorik - Jul-30-2020, 01:18 PM
RE: print CPU temperature - by Axel_Erfurt - Jul-30-2020, 02:13 PM
RE: print CPU temperature - by samuelbachorik - Jul-30-2020, 03:40 PM
RE: print CPU temperature - by snippsat - Jul-30-2020, 05:08 PM
RE: print CPU temperature - by Axel_Erfurt - Jul-30-2020, 05:59 PM
RE: print CPU temperature - by millpond - Jul-31-2020, 04:38 AM
RE: print CPU temperature - by Axel_Erfurt - Aug-04-2020, 03:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help gathering Temperature from API response road102 5 1,109 Dec-16-2022, 08:30 PM
Last Post: road102
  get data (temperature and humidity) from DHT22 into CSV and sending them over the net apollo 0 3,879 Apr-16-2021, 07:49 PM
Last Post: apollo
  monitoring the temperature of the CPU with Python apollo 2 8,868 Apr-13-2021, 05:39 PM
Last Post: apollo
  Read temperature once mada72 2 2,802 Apr-28-2019, 07:18 PM
Last Post: mada72
  Importing a temperature converting module RedSkeleton007 2 8,074 Nov-12-2017, 01:20 PM
Last Post: sparkz_alot
  Temperature Code help? 20AJ0931 2 6,579 Apr-08-2017, 12:35 AM
Last Post: snippsat
  Temperature value code 20AJ0931 10 13,566 Mar-19-2017, 11:05 PM
Last Post: 20AJ0931

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020