Click here to Skip to main content
15,884,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I implemented the code that obtaining hardware sensors' readings using OpenHardwareMonitor. The code looks like this: using OpenHardwareMonitor.Hardware;namespace WindowsFormsApp3{ public - Pastebin.com[^]

It basically searches for the "name" of the sensor and returns the value if the sensor was found.
While I can obtain CPU PPT, CPU Load, TCL/TDIE Temperature, and Temperature of CCD1 and CCD2, by no means I can find the CPU voltage or CPU or CORE frequency, regardless of what "names" I searching for.

If you ever worked with Open Hardware Monitor or a similar library, I would truly appreciate it if you would tell me which "names" are used for readings that I'm looking for.

What I have tried:

Searched for:
VCore
CPU Voltage
Voltage #1 (as it is named in OHM software)
Procesor Voltage
etc.
The same with a frequency.
During my research (when I didn't know that it will be a problem) I came across the code/console app that could successfully obtain CCD frequency, but I no longer can find it.
Posted
Updated 11-Jan-22 6:06am
Comments
BillWoodruff 11-Jan-22 3:11am    
Have you considered opening an issue on the GitHub site ?
0x01AA 11-Jan-22 8:25am    
I assume you also test with the demo app. Anyway in case I start the app as normal user I don't see e.g. Frequency Values. But if I start the app as Admin, the Frequency Values will be displayed....
I hope it helps.
0x01AA 11-Jan-22 11:39am    
Meanwhile I googled/read a lot about OpenHardwareMonitor and a lot of time people do not suggest it :(
Maybe it is more easy to get the values by WMI.

1 solution

I searched a lot to get a solution with OpenHardwareMonitor but I also had no success. Furthermore in a lot of posts I found a remark that OpenHardwareMonitor is not a good tool, but this I can't jugde.

During these researches I found this easy solution with WMI which maybe can solve your request or at least a part of it:

C#
using System.Management;
// ...
foreach (var item in new ManagementObjectSearcher("Select * from Win32_Processor").Get())
{
   Log($"CurrentVoltage [V]: {(decimal.Parse(item["CurrentVoltage"].ToString()) /
       10).ToString()}");
   Log($"CurrentClockSpeed [GHz]: {(decimal.Parse(item["CurrentClockSpeed"].ToString()) /
       1000).ToString()}");
}

Thanks to @Richard-MacCutchan, here a version without useless conversion to/from string:
C#
foreach (var item in new ManagementObjectSearcher("Select * from Win32_Processor").Get())
{
   Log($"CurrentVoltage [V]: {(ushort)item["CurrentVoltage"] / 10.0}");
   Log($"CurrentClockSpeed [GHz]: {(uint)item["CurrentClockSpeed"] / 1000.0}");
}


[Edit]
One correction more after recognizing that ManagementObjectSearcher is IDisposable *grrr*
using (var managementObjectSearcher = new ManagementObjectSearcher("Select * from Win32_Processor"))
{
    foreach (var item in managementObjectSearcher.Get())
    {
        Log($"CurrentVoltage [V]: {(ushort)(item["CurrentVoltage"]) / 10.0}");
        Log($"CurrentClockSpeed [GHz]: {(uint)item["CurrentClockSpeed"] / 1000.0}");
    }
}

[/Edit]

All properties which are available above you find here: Win32_Processor class - Win32 apps | Microsoft Docs[^]
 
Share this answer
 
v4
Comments
Richard MacCutchan 11-Jan-22 12:38pm    
You do not need either ToString or decimal.Parse on the values. The string formatter will automate it. In fact it is rather pointless to convert a numeric value to a string just so you can parse it back to a numeric.
0x01AA 11-Jan-22 12:45pm    
Thank you for the hint. This happens if one copy/paste code from other examples, my bad :(
Richard MacCutchan 11-Jan-22 14:34pm    
Yes, I have been caught by that many times.
0x01AA 11-Jan-22 14:51pm    
So I'm happy that I'm not the only one.

Other small question: Do you know why '@Richard-MacCutchan' does not appear as highlighted/link style? Does this not work in Q/A?
Richard MacCutchan 11-Jan-22 15:38pm    
No, the auto links only work in the forums.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900