4

Which python module is used to read CPU temperature and processor Fan speed in Windows?

I explored the WMI python module, however I am unable to find the correct option or function to capture the above mentioned info.

Actually I tried the following code snip, but it returns 'nothing'.

import wmi
w = wmi.WMI()
print w.Win32_TemperatureProbe()[0].CurrentReading

Is there a way to get this information?

Spevacus
  • 584
  • 2
  • 13
  • 23
msgsrk
  • 41
  • 1
  • 3
  • Possible duplicates http://stackoverflow.com/questions/2440511/getting-cpu-temperature-using-python and http://stackoverflow.com/questions/3262603/accessing-cpu-temperature-in-python – RanRag May 27 '12 at 20:09
  • This only works when run as administrator [http://stackoverflow.com/a/33905500/3500406](http://stackoverflow.com/a/33905500/3500406) – Neamerjell May 23 '16 at 07:38

2 Answers2

3

As per Microsoft's MSDN:

Most of the information that the Win32_TemperatureProbe WMI class provides comes from SMBIOS. Real-time readings for the CurrentReading property cannot be extracted from SMBIOS tables. For this reason, current implementations of WMI do not populate the CurrentReading property. The CurrentReading property's presence is reserved for future use.

You can use MSAcpi_ThermalZoneTemperature instead:

import wmi

w = wmi.WMI(namespace="root\\wmi")
print (w.MSAcpi_ThermalZoneTemperature()[0].CurrentTemperature/10.0)-273.15
Zeugma
  • 31,231
  • 9
  • 69
  • 81
  • Thank you for the solution. Is it possible to read CPU - FAN SPEED using python..? – msgsrk May 31 '12 at 04:50
  • I get a bunch of "unexpected" OLE/COM exceptions when I try doing this, why might that be? – Dan Jan 12 '14 at 20:12
0

This works perfectly:

import wmi

w = wmi.WMI(namespace="root\\wmi")
print (w.MSAcpi_ThermalZoneTemperature()[0].CurrentTemperature / 10.0) - 273.15

Make sure you're running the program as administrator, otherwise it will fail or give error codes when trying to test/run/execute your code.

trincot
  • 317,000
  • 35
  • 244
  • 286