views:

625

answers:

1

For a programming project I would like to access the temperature readings from my CPU and GPUs. I will be using C#. From various forums I get the impression that there is specific information and developer resources you need in order to access that information for various boards. I have a MSI NF750-G55 board. MSI's website does not have any of the information I am looking for. I tried their tech support and the rep I spoke with stated they do not have any such information. There must be a way to obtain that info.

Any thoughts?

+8  A: 

For at least the CPU side of things, you could use WMI.

The namespace\object is root\WMI, MSAcpi_ThermalZoneTemperature

Sample Code:

ManagementObjectSearcher searcher = 
    new ManagementObjectSearcher("root\\WMI",
                                 "SELECT * FROM MSAcpi_ThermalZoneTemperature");

ManagementObjectCollection.ManagementObjectEnumerator enumerator = 
    searcher.Get().GetEnumerator();

while(enumerator.MoveNext())
{
    ManagementBaseObject tempObject = enumerator.Current;
    Console.WriteLine(tempObject["CurrentTemperature"].ToString());
}

That will give you the temperature in a raw format. You have to convert from there:

kelvin = raw / 10;

celsius = (raw / 10) - 273.15;

farenheight = ((raw / 10) - 273.15) * 9 / 5 + 32;
Justin Niessner
I await with baited breath.
Paul
@Paul - Hopefully it doesn't disappoint.
Justin Niessner
I receive this error: 'enumerator.Current' threw an exception of type 'System.InvalidOperationException'
Aaron
@Aaron - Interesting. I wonder if your motherboard manufacturer supports this WMI monitoring (not all support it).
Justin Niessner
@Paul - Did this code work for you?
Aaron
@Aaron - I'm a newb and am working on implementing the code. So will see =].
Paul
I figured out how to implement the code however it I got an unhandled exception onwhile (enumerator.MoveNext())
Paul
@Paul - For what it's worth, I did test the code before posting. It could be that your hardware doesn't support the monitoring.
Justin Niessner