Question

I am taking a Arduino microcontroller class and I'm working on my final project: an automated computer cooling system that works according to case temperature.

I was unable to get my NVIDIA GPU core temp using the following sources: this MSDN link or this NVIDIA link. How can I get the value of the temperature of my GPU?

My knowledge in C# is basic and i couldn't make heads from tails on that manual or code examples in MSDN.

Was it helpful?

Solution

I'm gonna go ahead and answer my own question after a long time of searching how to do that i found a way to get the data.

Using the OpenHardwareMonitor.dll from their open source links i was able to get what i needed.

This is the code i used in a windows c# application (it might not be the best way to do it but it gets the job done.

Hope someone finds this helpful:

using OpenHardwareMonitor.Hardware;

. . .

public partial class mainWindow : Form
{

    Computer myComputer;

    public mainWindow()
    {
        InitializeComponent();

        myComputer = new Computer();
        myComputer.Open();
        myComputer.GPUEnabled = true;
        myComputer.CPUEnabled = true;
        foreach (var hardwareItem in myComputer.Hardware)
        {
            if (hardwareItem.HardwareType == HardwareType.GpuNvidia)
            {
                foreach (var sensor in hardwareItem.Sensors)
                {
                    if (sensor.SensorType == SensorType.Temperature)
                    {
                        GPUtemp.Text = String.Format(sensor.Value + "°C");
                    }
                }
            }
            if (hardwareItem.HardwareType == HardwareType.CPU)
            {
                foreach (var sensor in hardwareItem.Sensors)
                {
                    if (sensor.SensorType == SensorType.Temperature)
                    {
                        CPUtemp.Text = String.Format(sensor.Value + "°C");
                    }
                }
            }

        }
    }

    private void valueRefresh_Tick(object sender, EventArgs e)
    {
        myComputer = new Computer();
        myComputer.Open();
        myComputer.GPUEnabled = true;
        myComputer.CPUEnabled = true;
        foreach (var hardwareItem in myComputer.Hardware)
        {
            if (hardwareItem.HardwareType == HardwareType.GpuNvidia)
            {
                foreach (var sensor in hardwareItem.Sensors)
                {
                    if (sensor.SensorType == SensorType.Temperature)
                    {
                        GPUtemp.Text = String.Format(sensor.Value.ToString()); // write the value to a lable on the form
                    }
                }
            }
            if (hardwareItem.HardwareType == HardwareType.CPU)
            {
                foreach (var sensor in hardwareItem.Sensors)
                {
                    if (sensor.SensorType == SensorType.Temperature)
                    {
                        CPUtemp.Text = String.Format(sensor.Value.ToString());    // write the value to a lable on the form

                    }
                }
            }

        }
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top