Program reading CPU temperature incorrectly when put on new computer

339 Views Asked by At

I am trying to add a feature to an existing program that would display the current CPU core temperature using the Open Hardware Monitor. I have it working properly on my personal computer where it displays the temperature on a tool strip status label and refreshes on a timer. However, when I copy everything over to a new PC and test run the program the temperatures it returns are always coming back roughly 25 degrees higher than what the Monitor shows. If anyone has any ideas as to why it would read correctly on one computer but not another I would appreciate it as I'm stumped...

Here are the Monitor Temps and what my program is displaying on my PC both matched up.

Open Hardware Monitor temperatures

Temperature displayed in program

Now these are the temperatures displayed on the new PC that would be shipped out.

New PC Open Hardware Monitor

Program temperature display on New PC

This is the code I am currently using to get the temps.

Private Sub Timer3_Tick(sender As Object, e As EventArgs) Handles Timer3.Tick
    Dim cp As New Computer()
    cp.Open()
    cp.HDDEnabled = True
    cp.FanControllerEnabled = True
    cp.RAMEnabled = True
    cp.GPUEnabled = True
    cp.MainboardEnabled = True
    cp.CPUEnabled = True

    Dim Info As String = ""
    Timer3.Interval = 5000
    For i As Integer = 0 To cp.Hardware.Length - 1
        Dim hw = cp.Hardware(i)

        Select Case hw.HardwareType

            Case HardwareType.CPU

                ToolStripStatusLabel5.Text = "CPU" & vbCrLf
                For j = 0 To hw.Sensors.Length - 1
                    Dim sensor = hw.Sensors(j)
                    If cp.Hardware(i).Sensors(j).SensorType = SensorType.Temperature Then
                        ToolStripStatusLabel5.Text = sensor.Name & " - " & sensor.Value & vbCrLf
                    End If
                Next
        End Select
    Next

End Sub
1

There are 1 best solutions below

2
Julie Xu-MSFT On

I didn't see the error in the code, here is an example of using OpenHardwaremonitor and WMI to get the CPU temperature, maybe you can try it.