MSAcpi_ThermalZoneTemperature class not showing actual temperature

Posted by jchoudhury on Stack Overflow See other posts from Stack Overflow or by jchoudhury
Published on 2012-02-01T18:36:21Z Indexed on 2012/09/16 21:38 UTC
Read the original article Hit count: 1867

Filed under:

i want to fetch CPU Performance data in real time including temperature. i used the following code to get CPU Temperature:

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

            foreach (ManagementObject queryObj in searcher.Get())
            {
                double temp = Convert.ToDouble(queryObj["CurrentTemperature"].ToString());
                double temp_critical = Convert.ToDouble(queryObj["CriticalTripPoint"].ToString());
                double temp_cel = (temp/10 - 273.15);
                double temp_critical_cel = temp_critical / 10 - 273.15;
                lblCurrentTemp.Text = temp_cel.ToString();
                lblCriticalTemp.Text = temp_critical_cel.ToString();
            }
        }
        catch (ManagementException e)
        {
            MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
        }

but this code shows the temperature that is not the correct temperature. It ususally shows 49.5-50.5 degrees centigrade. But I used "OpenHardwareMonitor" that report CPU temperature over 71 degree centigrade and changing fractions along with time fractions. is there anything I am missing in the code?

I used the above code in timer_click event for every 500ms interval to refresh the temperature reading but it's always showing the same temperature from the beginning of execution. That implies if you run this application and if it shows 49 degree then after 1 hour session, it'll constantly show 49 degree. Where is the problem? please help. Thanks in advance.

© Stack Overflow or respective owner

Related posts about c#