如何以整数值获取 NVIDIA 核心温度? [英] How do I get the NVIDIA core temperature in an integer value?

查看:19
本文介绍了如何以整数值获取 NVIDIA 核心温度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习 Arduino 微控制器课程,我正在做我的最后一个项目:一个根据外壳温度工作的自动计算机冷却系统.

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.

我无法使用以下来源获得我的 NVIDIA GPU 核心温度:此 MSDN 链接此 NVIDIA 链接.如何获取 GPU 的温度值?

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?

我对 C# 的了解是基本的,我无法从那些手册或 MSDN 中的代码示例中得出结论.

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

推荐答案

经过长时间的搜索,我找到了获取数据的方法后,我将继续回答我自己的问题.

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.

使用来自他们的开源链接的 OpenHardwareMonitor.dll 我能够得到我需要的东西.

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

这是我在 windows c# 应用程序中使用的代码(它可能不是最好的方法,但它可以完成工作.

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

                    }
                }
            }

        }
    }
}

这篇关于如何以整数值获取 NVIDIA 核心温度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆