Alexander
Alexander

Reputation: 12795

openhardwaremonitor get only GPU temp

I am trying to get my (nvidia) GPU temperature reading from a c# project. There is already a solution for that, using openhardwaremonitor dll file.

This is my code :

using OpenHardwareMonitor.Hardware;

...

Computer myComputer = new Computer();
myComputer.GPUEnabled = true;
myComputer.Open();

foreach (var hardwareItem in myComputer.Hardware)
{
    if (hardwareItem.HardwareType == HardwareType.GpuNvidia)
    {     
       foreach (var sensor in hardwareItem.Sensors)
       {
           Console.WriteLine(sensor.Identifier.ToString() + ":" + sensor.Value.ToString());
       }                   
    }
}

This results in the following output:

/nvidiagpu/0/clock/0:
/nvidiagpu/0/clock/1:
/nvidiagpu/0/clock/2:
/nvidiagpu/0/load/3:1.324463

This is a code to get a full hardware report:

Computer myComputer = new Computer();
myComputer.GPUEnabled = true;
myComputer.Open();
Console.Write(myComputer.GetReport());

This is what i got in return :

    Open Hardware Monitor Report

--------------------------------------------------------------------------------

Version: 0.7.1.0

--------------------------------------------------------------------------------

Common Language Runtime: 4.0.30319.42000
Operating System: Microsoft Windows NT 10.0.15063.0
Process Type: 32-Bit

--------------------------------------------------------------------------------

Sensors

|
+- NVIDIA GeForce 840M (/nvidiagpu/0)
| +- GPU Core : (/nvidiagpu/0/clock/0)
| +- GPU Memory : (/nvidiagpu/0/clock/1)
| +- GPU Shader : (/nvidiagpu/0/clock/2)
| +- GPU Memory : 1.32446 1.32446 1.32446 (/nvidiagpu/0/load/3)

--------------------------------------------------------------------------------

Parameters

|
+- NVIDIA GeForce 840M (/nvidiagpu/0)

--------------------------------------------------------------------------------

AMD Display Library

Status: -1

--------------------------------------------------------------------------------

NVAPI

Version: NVidia Complete Version 1.10
Number of GPUs: 1

--------------------------------------------------------------------------------

Nvidia GPU

Name: NVIDIA GeForce 840M
Index: 0
Driver Version: 382.05
Driver Branch: r381_99-3

DeviceID: 0x134110DE
SubSystemID: 0x504217AA
RevisionID: 0xA2
ExtDeviceID: 0x1341

Thermal Settings

Sensor[0].Controller: GPU_INTERNAL
Sensor[0].DefaultMinTemp: 0
Sensor[0].DefaultMaxTemp: 127
Sensor[0].CurrentTemp: 41
Sensor[0].Target: GPU

Clocks

Clock[8]: 405000
Clock[9]: 11
Clock[10]: 277778
Clock[11]: 1
Clock[30]: 810000
Clock[31]: 17
Clock[32]: 737678
Clock[33]: 25
Clock[34]: 793800
Clock[35]: 25
Clock[36]: 648000
Clock[37]: 9
Clock[40]: 324000
Clock[41]: 9
Clock[44]: 108000
Clock[45]: 1
Clock[92]: 405000
Clock[93]: 32
Clock[99]: 277778
Clock[100]: 32
Clock[169]: 810000
Clock[170]: 32
Clock[176]: 737678
Clock[177]: 15
Clock[178]: 91
Clock[183]: 793800
Clock[184]: 15
Clock[185]: 98
Clock[190]: 648000
Clock[191]: 32
Clock[204]: 324000
Clock[205]: 32
Clock[218]: 108000
Clock[219]: 32

Tachometer

Status: NOT_SUPPORTED

P-States

Percentage[0]: 0
Percentage[1]: 0
Percentage[2]: 0
Percentage[3]: 0

Usages

Usage[1]: 1
Usage[3]: 60
Usage[4]: 30
Usage[5]: 1
Usage[7]: 58
Usage[8]: 29
Usage[9]: 1
Usage[11]: 58
Usage[12]: 29
Usage[13]: 1
Usage[15]: 100
Usage[16]: 100

Cooler Settings


Memory Info

Value[0]: 2097152
Value[1]: 2069376
Value[2]: 0
Value[3]: 4150644
Value[4]: 2069376

As you can see the temperature reading is there , but i could not find a way to get it programmatically. Obviously i can parse the returned string and get the temperature reading, but i would feel really bad doing it.

Would be happy to get any insight on this.

Upvotes: 1

Views: 3697

Answers (1)

I think you have already found a solution. If not, then here is the code.

foreach (var sensor in hardwareItem.Sensors)
{
    if (sensor.SensorType == SensorType.Temperature)
    {
        Console.WriteLine(sensor.Value.ToString());
        Console.WriteLine(sensor.Identifier.ToString() + ":" + sensor.Value.ToString());
    }
}

Upvotes: 2

Related Questions