How to get the CPU Temperature info from Bios using c#?
Asked Answered
R

3

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"

Rohrer answered 1/9, 2010 at 2:51 Comment(11)
You'll need to obtain an improved WMI provider from your motherboard manufacturer. Don't count on getting one.Lazarolazaruk
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.Dissidence
Is there any other way to do it OR what can i do to make it support WMI ? Thanks.Rohrer
@linuxuser27, i want to do this task programatically.Rohrer
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.Dissidence
@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.Rohrer
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.Dissidence
@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...Rohrer
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.Dissidence
@linuxuser27, WMI is the only way to access CPU temp. info ?Rohrer
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.Dissidence
M
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

Maloney answered 3/9, 2010 at 0:34 Comment(0)
E
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

Essonite answered 3/9, 2010 at 7:8 Comment(0)
O
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.

Outlawry answered 3/4, 2012 at 13:53 Comment(1)
Here is a relevant document from Intel, CPU Monitoring with DTS/PECI from September 2010, download.intel.com/design/intarch/papers/322683.pdf with some information about interpretation of temperature data from Intel processors.Eulalie
M
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

Maloney answered 3/9, 2010 at 0:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.