8

How to get the CPU Temperature info from Bios using c# I gave a try to the code in CPU temperature monitoring

But no luck. 'enumerator.Current' threw an exception.

How can i achieve this ? Thanks.

Error :

"This system doesn't support the required WMI objects(1) - check the exception file \r\nNot supported \r\n\r\n at System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode)\r\n at System.Management.ManagementObjectCollection.ManagementObjectEnumerator.MoveNext()\r\n at CedarLogic.WmiLib.SystemStatistics.RefreshReadings() in D:\Downloads\TempMonitorSrc\TemperatureMonitorSln\WmiLib\SystemStatistics.cs:line 25\r\n at CedarLogic.WmiLib.SystemStatistics.get_CurrentTemperature() in D:\Downloads\TempMonitorSrc\TemperatureMonitorSln\WmiLib\SystemStatistics.cs:line 87\r\n at TemperatureMonitor.SystemTrayService.CheckSupport() in D:\Downloads\TempMonitorSrc\TemperatureMonitorSln\TemperatureMonitor\SystemTrayService.cs:line 260"

Community
  • 1
  • 1
Anuya
  • 8,082
  • 49
  • 137
  • 222
  • 2
    You'll need to obtain an improved WMI provider from your motherboard manufacturer. Don't count on getting one. – Hans Passant Sep 01 '10 at 02:56
  • You can look at all WMI objects with the "WMI Studio". It is an explorer for WMI objects. You can find it with your favorite search engine. – linuxuser27 Sep 01 '10 at 03:03
  • Is there any other way to do it OR what can i do to make it support WMI ? Thanks. – Anuya Sep 01 '10 at 03:04
  • @linuxuser27, i want to do this task programatically. – Anuya Sep 01 '10 at 03:07
  • 1
    Yeah I understand that. I was just mentioning that tool so you could actually see what WMI objects are available. The name of the object may have changed based on what version of Windows you are using. – linuxuser27 Sep 01 '10 at 03:10
  • @linuxuser27, i checked with the tool u specified. There is a class called "MSAcpi_ThermalXOneTemperature" But it says the selected class do not have instance. – Anuya Sep 01 '10 at 03:15
  • 1
    No instances means you are out of luck. Unfortunately 'Hans Passant' is correct. If there are no instances of the classes in question or you are unable to find an object there that will give you this information you will have to get a WMI provider from your manufacturer. – linuxuser27 Sep 01 '10 at 03:18
  • @linuxuser27, One thing i want to be clear. Is it like nothing can be done on this mother board i have now OR i can use some driver for WMI provider ? I am new to WMI... – Anuya Sep 01 '10 at 03:22
  • 1
    This is not a driver issue. It is a WMI component that uses an underlying driver. There maybe a driver for this component that you have installed, but there does not seem to be a WMI component that supports that driver. WMI is just an abstraction for system management. – linuxuser27 Sep 01 '10 at 03:33
  • @linuxuser27, WMI is the only way to access CPU temp. info ? – Anuya Sep 01 '10 at 03:36
  • 1
    I honestly have no idea. I am sure there are other mechanisms, but I do not know them. There are other WMI objects that give information regarding temperature. These classes can be found in `root\CIMV2` under `CIM_ManagedSystemElement\CIM_LogicalElement\CIM_LogicalDevice`. These classes contain a lot of information, not just temp. You might find what you are looking for there. Good luck. – linuxuser27 Sep 01 '10 at 03:57

3 Answers3

2

You need to support many diffrent hardware sensors to gather temperature data. Better way is to take ready to use solutions like these:

1) Open Hardware Monitor - open source .NET 2.0 Application:

http://openhardwaremonitor.org/

2) Core Temp - free application and .NET API to get temperature data:

http:// www.alcpu.com/CoreTemp/developers.html

1

I know this thread is old, but I wanted to add to it with a bit of a different approach. Get the make/model off the I/O chip on the motherboard and get the data sheet for said I/O chip (I will use an ITE IT8783F chip for reference here). Look under something like Environment Controller and calculate the access and read ports. Yes ... you will have to understand HEX and MSB and LSB and I won't go into the calculations/explanation here (out of scope). Now, in this instance the access port is 295 and the read port is 296. Reading further down in the section there is a table for the Environment Controller Registers. In this instance, the CPU temperature is in register 2Ah (or 0x2A). So, the VB/C# code I used to pull the info looks like this:

Private Function GetCPUTemp() As UInt32
    Dim tCpu As UInt32
    Dim stCpu As Short
    PortAccess.Outputb(&H295, &H2A)
    stCpu = PortAccess.Inputb(&H296)
    tCpu = CType(stCpu, UInt32)
    Return tCpu
End Function

Now, you just have to figure out what you want to do with it. Remember, if you find that you are getting crazy wacky numbers, you either are pulling from the wrong register or you may need to implement a scaling factor (as you do with voltage readings). This, too, should be in the data sheet.

Highroller
  • 41
  • 4
  • Here is a relevant document from Intel, CPU Monitoring with DTS/PECI from September 2010, http://download.intel.com/design/intarch/papers/322683.pdf with some information about interpretation of temperature data from Intel processors. – Richard Chambers Jan 13 '13 at 04:53
0

I would recommend the following approach. There are several free applications that monitor the CPU temp and display it. Try downloading some and then analyse the application to see what methods they are calling in order to discover how they work. Maybe they have a very different approach to your existing one. Also you might be able to just email them and ask how they did it...

http://www.alcpu.com/CoreTemp/

http://www.techpowerup.com/realtemp/

http://malektips.com/core-temp-cpu-windows-system-tray-taskbar.html

Phil Wright
  • 22,580
  • 14
  • 83
  • 137