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

前端 未结 1 1405
[愿得一人]
[愿得一人] 2020-12-22 08: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 wa

相关标签:
1条回答
  • 2020-12-22 08:49

    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
    
                        }
                    }
                }
    
            }
        }
    }
    
    0 讨论(0)
提交回复
热议问题