How do I get the NVIDIA core temperature in an integer value?

别说谁变了你拦得住时间么 提交于 2019-12-18 09:38:09

问题


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.


回答1:


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

                    }
                }
            }

        }
    }
}


来源:https://stackoverflow.com/questions/22894050/how-do-i-get-the-nvidia-core-temperature-in-an-integer-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!