How to get the CPU and GPU temperature? #965
Replies: 2 comments
-
Did you try the sample provided? This is how I personally do it, first loop through the hardware and check its type like this; if (hardware.HardwareType is HardwareType.Cpu)
// CPU
if (hardware.HardwareType is HardwareType.GpuNvidia or HardwareType.GpuAmd or HardwareType.GpuIntel)
// GPU Then once you have isolated the hardware, you can iterate through its sensors. I have separate classes for this, but typically you'll want to check for names like These names can probably be somewhat different between hardware I reckon, and some processors return no values at all. For example my i9 12900F reports not only temperature, but also load, draw and voltage. My girlfriend's CPU (i5 3570K) returns neither temperatures nor draw. Here's an example of how I currently query the CPU sensors; IHardware Hardware { get; set; }
ISensor? Power { get; set; }
ISensor? Temperature { get; set; }
ISensor? Load { get; set; }
void FindSensors()
{
foreach (var sensor in Hardware.Sensors)
{
if (sensor.Name.Contains("Total", StringComparison.InvariantCultureIgnoreCase) || sensor.Name.Contains("Package", StringComparison.InvariantCultureIgnoreCase)))
{
//Debug.WriteLine($"CPU Sensor: {sensor.Name} Type: {sensor.SensorType}");
switch (sensor.SensorType)
{
case SensorType.Power:
Power = sensor;
break;
case SensorType.Temperature:
Temperature = sensor;
break;
case SensorType.Load:
Load = sensor;
break;
}
}
}
} That should be enough to help you get started, assuming you follow the sample provided. |
Beta Was this translation helpful? Give feedback.
-
Do you have a complete code example, including the |
Beta Was this translation helpful? Give feedback.
-
How to get the CPU and GPU temperature?
Beta Was this translation helpful? Give feedback.
All reactions