locked
Retrieving CPU/Motherboard temp/voltages/fan speeds etc RRS feed

  • Question

  • Hi

    Trying to add facility to my app to show things like CPU/Motherboard temperature / voltages / fan speeds etc

    Found that information retrieved from WMI is inaccurate and can't get half of what I need

    So researched more and found http://openhardwaremonitor.org/ which has a DLL you can use in your own apps

    I have looked through the odd sample in c# I can find but having troubles implementing it

    Just wondered if anyone else had experience using the OpenHardwareMonitorLib.dll and getting information needed?

    Below code will show me list of all hardware in my system which has sensors, but can't then see how to get the sensor results

    Thanks

    Imports OpenHardwareMonitor
    Imports OpenHardwareMonitor.Hardware
    
    Public Class Form1
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim cp As New Computer()
            cp.Open()
            cp.HDDEnabled = True
            cp.FanControllerEnabled = True
            cp.RAMEnabled = True
            cp.GPUEnabled = True
            cp.MainboardEnabled = True
            cp.CPUEnabled = True
    
            Dim Info As String = ""
            For i As Integer = 0 To cp.Hardware.Count() - 1
    
    
                If cp.Hardware(i).HardwareType = HardwareType.Mainboard Then
                    Info += " Motherboard: " & Trim(cp.Hardware(i).Name) & vbCrLf
                End If
                If cp.Hardware(i).HardwareType = HardwareType.CPU Then
                    Info += " Processor: " & Trim(cp.Hardware(i).Name) & vbCrLf
                End If
                If cp.Hardware(i).HardwareType = HardwareType.GpuNvidia Then
                    Info += " Video Card: " & Trim(cp.Hardware(i).Name) & vbCrLf
                End If
                If cp.Hardware(i).HardwareType = HardwareType.RAM Then
                    Info += " RAM: " & Trim(cp.Hardware(i).Name) & vbCrLf
                End If
                If cp.Hardware(i).HardwareType = HardwareType.HDD Then
                    Info += " HDD: " & Trim(cp.Hardware(i).Name) & vbCrLf
                End If
                If cp.Hardware(i).HardwareType = HardwareType.SuperIO Then
                    Info += " SuperIO: " & Trim(cp.Hardware(i).Name) & vbCrLf
                End If
            Next
            TextBox1.Text = Info
    
        End Sub
    
    End Class


    Darren Rose

    Saturday, March 28, 2015 4:06 PM

Answers

  • Certainly that source code mentions fans, temps etc for motherboard so must be missing something = https://code.google.com/p/open-hardware-monitor/source/browse/trunk/Hardware/Mainboard/SuperIOHardware.cs


    Darren Rose

    Yea when you found it then please show it here?

    Can be interesting.


    Success
    Cor

    Hi

    Have found out why Open Hardware Monitor wasn't showing fans and some other sensors

    I had to add in the line subhardware.Update() and now it works fine

    Amended code copied below for anyone else who may find it useful:-

    For i As Integer = 0 To cp.Hardware.Count() - 1
                Dim hardware = cp.Hardware(i)
                hardware.Update()
    
                Select Case hardware.HardwareType
                    Case HardwareType.Mainboard
                        TextBox3.AppendText("Motherboard: " & hardware.Name & vbCrLf & vbCrLf)
                        For k = 0 To hardware.SubHardware.Count - 1
                            Dim subhardware = hardware.SubHardware(k)
                            subhardware.Update()
                            TextBox3.AppendText(subhardware.Name & vbCrLf & vbCrLf)
                            For j = 0 To subhardware.Sensors.Count - 1
                                Dim sensor = subhardware.Sensors(j)
                                Select (sensor.SensorType)
                                    Case 0
                                        TextBox3.AppendText("Voltage: " & sensor.Name & " - " & sensor.Value & vbCrLf)
                                    Case 1
                                        TextBox3.AppendText("Clock: " & sensor.Name & " - " & sensor.Value & vbCrLf)
                                    Case 2
                                        TextBox3.AppendText("Temperature: " & sensor.Name & " - " & sensor.Value & vbCrLf)
                                    Case 3
                                        TextBox3.AppendText("Load: " & sensor.Name & " - " & sensor.Value & vbCrLf)
                                    Case 4
                                        TextBox3.AppendText("Fan Speed: " & sensor.Name & " - " & sensor.Value & vbCrLf)
                                    Case 5
                                        TextBox3.AppendText("Flow: " & sensor.Name & " - " & sensor.Value & vbCrLf)
                                    Case 6
                                        TextBox3.AppendText("Fan Control: " & sensor.Name & " - " & sensor.Value & vbCrLf)
                                    Case 7
                                        TextBox3.AppendText("Level: " & sensor.Name & " - " & sensor.Value & vbCrLf)
                                    Case 8
                                        TextBox3.AppendText("Factor: " & sensor.Name & " - " & sensor.Value & vbCrLf)
                                    Case 9
                                        TextBox3.AppendText("Power: " & sensor.Name & " - " & sensor.Value & vbCrLf)
                                    Case 10
                                        TextBox3.AppendText("Data: " & sensor.Name & " - " & sensor.Value & vbCrLf)
                                    Case Else
                                        TextBox3.AppendText(sensor.SensorType & " - " & sensor.Name & " - " & sensor.Value & vbCrLf)
                                End Select
                            Next
                            TextBox3.AppendText(vbCrLf)
                        Next
    
    End Select


    Darren Rose

    • Marked as answer by wingers Thursday, April 9, 2015 10:47 AM
    Thursday, April 9, 2015 10:47 AM

All replies

  • Darren,

    I don't know about the assembly you found, but to the original issue with WMI, you might want to have a look at this thread. Be sure to read all of them - including the last one.

    It seems that WMI isn't really all it's cracked up to be?


    Still lost in code, just at a little higher level.

    :-)

    Saturday, March 28, 2015 4:26 PM
  • Darren,

    I don't know about the assembly you found, but to the original issue with WMI, you might want to have a look at this thread. Be sure to read all of them - including the last one.

    It seems that WMI isn't really all it's cracked up to be?


    Still lost in code, just at a little higher level.

    :-)

    Thanks Frank - yes I had stumbled across that article earlier - does seem, especially for hardware related information that is not much use as always relies on hardware manufacturers publishing correct information to WMI - that was main reason I searched for alternative way of doing it - seems like the assembly I mentioned would do it perfectly as the demo app (without source) they provide shows all the information I need (and have tried it on lots of computers to double check results)


    Darren Rose

    Saturday, March 28, 2015 4:37 PM
  • Darren,

    You might be onto something then. :)


    Still lost in code, just at a little higher level.

    :-)

    Saturday, March 28, 2015 4:41 PM
  • Did you run with Admin rights.  The docs for the dll state that most hardware sensors are not available unless running with Admin rights.  There is also a method to get the source code if you need it also on the same page.

    Lloyd Sheen

    Saturday, March 28, 2015 4:54 PM
  • Did you run with Admin rights.  The docs for the dll state that most hardware sensors are not available unless running with Admin rights.  There is also a method to get the source code if you need it also on the same page.

    Lloyd Sheen

    yes I am running the app as admin - and it is listing all hardware items with sensors, it is just working out how to then get sensor details from that

    source code on page is in c# and I work in vb.net - tried converting it, but it has so many separate files/classes etc, it is very difficult to find what I need - hence asking on here in case any one had samples or ideas from using it in vb.net


    Darren Rose

    Saturday, March 28, 2015 4:56 PM
  • Did you run with Admin rights.  The docs for the dll state that most hardware sensors are not available unless running with Admin rights.  There is also a method to get the source code if you need it also on the same page.


    Lloyd Sheen

    yes I am running the app as admin - and it is listing all hardware items with sensors, it is just working out how to then get sensor details from that

    source code on page is in c# and I work in vb.net - tried converting it, but it has so many separate files/classes etc, it is very difficult to find what I need - hence asking on here in case any one had samples or ideas from using it in vb.net


    Darren Rose

    Hello,

    Issues related to third-party are not supported here, and to get help about that dll, you could connect to its publisher.

    I found that website did contain "Support" page, and you could consider connecting with them by Email, they also provided the email account on that site.

    Regards,

    Carl


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    • Edited by Carl Cai Monday, March 30, 2015 6:58 AM
    • Proposed as answer by Cor Ligthert Monday, March 30, 2015 7:40 AM
    • Unproposed as answer by wingers Monday, March 30, 2015 2:23 PM
    Monday, March 30, 2015 6:57 AM
  • In addition to Carl,

    You are not the first asking this here. However, the problems are almost forever related to the DLL and the kind of hardware which is used. 

    Also be aware that a DLL for this which gave results on XP, often give only errors on W8 because of more security protections.


    Success
    Cor

    Monday, March 30, 2015 7:42 AM
  • Okay thanks - didn't realise I couldn't ask about 3rd party tools in this forum - sure I have done before and seen others do so, but not to worry

    Yes the problem could be with the DLL, but as I said the app they supply (without source) retrieves all values fine - and as that uses the same DLL it obviously works - hence trying to use it

    Already tried the support section on that site - will try emailing

    Thanks for all your replies


    Darren Rose

    Monday, March 30, 2015 9:17 AM
  • Darren,

    You can ask, however, the chance on a reliable answer on a problem with an Alfa in a Mercedes garage is much lower than in an Alfa garage.

    That Microsoft (Pacetera) does not support things does not mean that persons watching this forum have not used it related to VB for .Net. (I don't know if you have an MSDN subscribtion because then the message from Carl comes in another meaning and is it not supported by MSDN)


    Success
    Cor



    Monday, March 30, 2015 9:22 AM
  • I'm not sure why admin rights are discussed. I thought the problem is how to get the sensor values.

    Darren, if this is still the issue: Hardware objects have a "Sensors" property. That's what the homepage of that tool tells me. So, something like this should work:     

     For i As Integer = 0 To cp.Hardware.Count() - 1
           dim hw=cp.Hardware(i)

    select case hw.HardwareType
    case HardwareType.Mainboard
    '...
    case ...
    end Select

    for j=0 to hw.Sensors.Count
    dim sensor=hw.sensors(j)
    '....
    next
    Next


    In any case, even without a documentation, you always have the chance to look at the members of what you are utilizing by using intellisense or the object browser.


    Armin

    Monday, March 30, 2015 11:31 AM
  • Thanks for your reply Armin

    Yes that is correct admin rights not the issue

    Using the idea from your code I can now get some values back - but still issues with motherboard only returning 3 x fan controls - and not showing sensors OR values for voltages, temperature and fan speed

    CPU returns all values

    RAM finds three sensors, but values returned as 0

    The demo program on the website using the DLL shows all these things correctly

    My revised code below:-

    For i As Integer = 0 To cp.Hardware.Count() - 1
                Dim hw = cp.Hardware(i)
    
                Select Case hw.HardwareType
                    Case HardwareType.Mainboard
                        TextBox3.AppendText("Motherboard" & vbCrLf)
                        For k = 0 To hw.SubHardware.Count - 1
                            Dim subhardware = hw.SubHardware(k)
                            TextBox3.AppendText(subhardware.Name & vbCrLf)
                            For j = 0 To subhardware.Sensors.Count - 1
                                Dim sensor = subhardware.Sensors(j)
                                TextBox3.AppendText(sensor.SensorType & " - " & sensor.Name & " - " & sensor.Value & vbCrLf)
                            Next
                        Next
                    Case HardwareType.CPU
                        TextBox3.AppendText("CPU" & vbCrLf)
                        For j = 0 To hw.Sensors.Count - 1
                            Dim sensor = hw.Sensors(j)
                            TextBox3.AppendText(sensor.SensorType & " - " & sensor.Name & " - " & sensor.Value & vbCrLf)
                        Next
                    Case HardwareType.RAM
                        TextBox3.AppendText("RAM" & vbCrLf)
                        For j = 0 To hw.Sensors.Count - 1
                            Dim sensor = hw.Sensors(j)
                            TextBox3.AppendText(sensor.SensorType & " - " & sensor.Name & " - " & sensor.Value & vbCrLf)
                        Next
                End Select
            Next


    Darren Rose

    Monday, March 30, 2015 2:18 PM
  • I think this is only information specific to that library that you can find on the author's homepage or ask there if you won't find another example in the web anywhere. I'm afraid, I can also only follow the link on the homepage to the source code: https://code.google.com/p/open-hardware-monitor/source/browse/#svn%2Ftrunk%2FHardware, so I suggest you have a look there.

    Armin

    Monday, March 30, 2015 2:57 PM
  • okay thanks - will do - have also emailed the author - as seems strange his own app using that DLL shows fans speeds etc

    Darren Rose

    Monday, March 30, 2015 2:59 PM
  • Certainly that source code mentions fans, temps etc for motherboard so must be missing something = https://code.google.com/p/open-hardware-monitor/source/browse/trunk/Hardware/Mainboard/SuperIOHardware.cs

    Darren Rose

    Monday, March 30, 2015 3:11 PM
  • Certainly that source code mentions fans, temps etc for motherboard so must be missing something = https://code.google.com/p/open-hardware-monitor/source/browse/trunk/Hardware/Mainboard/SuperIOHardware.cs

    Darren Rose

    Yea when you found it then please show it here?

    Can be interesting.


    Success
    Cor

    Monday, March 30, 2015 9:16 PM
  • Yea when you found it then please show it here?

    Can be interesting.


    Success
    Cor

    Yes I will definitely update forum IF I find solution - very strange as cannot see why same DLL in the app they provide can get info I need - but using DLL in my own app it only gives some of it - checked DLL versions - tried looking through source of sample app in C# but it is quite a complex app and trying to understand/find what I need difficult as I don't work in C# only vb.net

    Darren Rose

    Monday, March 30, 2015 9:37 PM
  • I will make a guess that all these namespaces or classes, listed under Hardware, make up the .DLL to which you refer. Most of which use API's it appears.

    Filename Size Rev Date Author
    Computer.cs 11.0 KB r408 Jul 23, 2012 moel.mich
    Control.cs 3.2 KB r469 Dec 30, 2014 moel.mich
    FirmwareTable.cs 3.1 KB r382 May 27, 2012 moel.mich
    Hardware.cs 2.7 KB r382 May 27, 2012 moel.mich
    HexStringArray.cs 1005 bytes r382 May 27, 2012 moel.mich
    IComputer.cs 827 bytes r408 Jul 23, 2012 moel.mich
    IControl.cs 721 bytes r469 Dec 30, 2014 moel.mich
    IElement.cs 583 bytes r382 May 27, 2012 moel.mich
    IGroup.cs 472 bytes r382 May 27, 2012 moel.mich
    IHardware.cs 980 bytes r408 Jul 23, 2012 moel.mich
    IOControlCode.cs 1.1 KB r382 May 27, 2012 moel.mich
    IParameter.cs 628 bytes r382 May 27, 2012 moel.mich
    ISensor.cs 1.5 KB r382 May 27, 2012 moel.mich
    ISettings.cs 564 bytes r382 May 27, 2012 moel.mich
    IVisitor.cs 564 bytes r382 May 27, 2012 moel.mich
    Identifier.cs 2.7 KB r382 May 27, 2012 moel.mich
    KernelDriver.cs 10.0 KB r420 Sep 23, 2012 moel.mich
    Opcode.cs 9.9 KB r382 May 27, 2012 moel.mich
    OperatingSystem.cs 1.0 KB r399 Jul 11, 2012 moel.mich
    PInvokeDelegateFactory.cs 3.0 KB r424 Oct 27, 2012 moel.mich
    Parameter.cs 3.0 KB r382 May 27, 2012 moel.mich
    Ring0.cs 12.1 KB r420 Sep 23, 2012 moel.mich
    SMBIOS.cs 15.4 KB r418 Aug 11, 2012 moel.mich
    Sensor.cs 7.0 KB r415 Jul 25, 2012 moel.mich
    SensorVisitor.cs 1.1 KB r382 May 27, 2012 moel.mich
    ThreadAffinity.cs 2.0 KB r474 Dec 30, 2014 moel.mich
    WinRing0.sys 14.1 KB r270 Oct 31, 2010 moel.mich
    WinRing0x64.sys 14.2 KB r270 Oct 31, 2010 moel.mich

    This is what is listed under WMI

    Filename Size Rev Date Author
    Hardware.cs 1.1 KB r382 May 27, 2012 moel.mich
    IWmiObject.cs 496 bytes r382 May 27, 2012 moel.mich
    Sensor.cs 1.4 KB r382 May 27, 2012 moel.mich
    WmiProvider.cs 3.5 KB r430 Nov 19, 2012 moel.mich

    I downloaded 0.7.1 Beta and no fan speed is showing. I have everything selected to show and this is all that displays. Perhaps you should try C# to VB converters to convert code so you can see what it does.


    La vida loca




    Tuesday, March 31, 2015 3:56 AM

  • I downloaded 0.7.1 Beta and no fan speed is showing. I have everything selected to show and this is all that displays. Perhaps you should try C# to VB converters to convert code so you can see what it does.




    Probably then your mainboard is not supported with this. I use Asus and see all kind of fan speeds (including even my videoadapter).

    I'm not sure the C# goes, at least not for me. The given namespace is not related to the downloaded one as far as I can see.


    Success
    Cor


    Tuesday, March 31, 2015 6:53 AM
  • Thanks for your replies

    Yes I did try converting some of the c# but so many files, hard to work out which one does what to find issue - as I say it gets all other sensors, so must be some difference between the DLL to use for own apps and the beta program they supply to test it

    Also I am finding it doesn't work on some motherboards so not that reliable

    Back to the drawing board then - any other ideas for getting this info accurately?

    Both CPUID and HWINFO do SDK's to add functionality into your own apps, but at quite a price!!


    Darren Rose

    Tuesday, March 31, 2015 12:13 PM
  • Certainly that source code mentions fans, temps etc for motherboard so must be missing something = https://code.google.com/p/open-hardware-monitor/source/browse/trunk/Hardware/Mainboard/SuperIOHardware.cs


    Darren Rose

    Yea when you found it then please show it here?

    Can be interesting.


    Success
    Cor

    Hi

    Have found out why Open Hardware Monitor wasn't showing fans and some other sensors

    I had to add in the line subhardware.Update() and now it works fine

    Amended code copied below for anyone else who may find it useful:-

    For i As Integer = 0 To cp.Hardware.Count() - 1
                Dim hardware = cp.Hardware(i)
                hardware.Update()
    
                Select Case hardware.HardwareType
                    Case HardwareType.Mainboard
                        TextBox3.AppendText("Motherboard: " & hardware.Name & vbCrLf & vbCrLf)
                        For k = 0 To hardware.SubHardware.Count - 1
                            Dim subhardware = hardware.SubHardware(k)
                            subhardware.Update()
                            TextBox3.AppendText(subhardware.Name & vbCrLf & vbCrLf)
                            For j = 0 To subhardware.Sensors.Count - 1
                                Dim sensor = subhardware.Sensors(j)
                                Select (sensor.SensorType)
                                    Case 0
                                        TextBox3.AppendText("Voltage: " & sensor.Name & " - " & sensor.Value & vbCrLf)
                                    Case 1
                                        TextBox3.AppendText("Clock: " & sensor.Name & " - " & sensor.Value & vbCrLf)
                                    Case 2
                                        TextBox3.AppendText("Temperature: " & sensor.Name & " - " & sensor.Value & vbCrLf)
                                    Case 3
                                        TextBox3.AppendText("Load: " & sensor.Name & " - " & sensor.Value & vbCrLf)
                                    Case 4
                                        TextBox3.AppendText("Fan Speed: " & sensor.Name & " - " & sensor.Value & vbCrLf)
                                    Case 5
                                        TextBox3.AppendText("Flow: " & sensor.Name & " - " & sensor.Value & vbCrLf)
                                    Case 6
                                        TextBox3.AppendText("Fan Control: " & sensor.Name & " - " & sensor.Value & vbCrLf)
                                    Case 7
                                        TextBox3.AppendText("Level: " & sensor.Name & " - " & sensor.Value & vbCrLf)
                                    Case 8
                                        TextBox3.AppendText("Factor: " & sensor.Name & " - " & sensor.Value & vbCrLf)
                                    Case 9
                                        TextBox3.AppendText("Power: " & sensor.Name & " - " & sensor.Value & vbCrLf)
                                    Case 10
                                        TextBox3.AppendText("Data: " & sensor.Name & " - " & sensor.Value & vbCrLf)
                                    Case Else
                                        TextBox3.AppendText(sensor.SensorType & " - " & sensor.Name & " - " & sensor.Value & vbCrLf)
                                End Select
                            Next
                            TextBox3.AppendText(vbCrLf)
                        Next
    
    End Select


    Darren Rose

    • Marked as answer by wingers Thursday, April 9, 2015 10:47 AM
    Thursday, April 9, 2015 10:47 AM
  • Darren

    Thanks for sharing this with the community


    Success
    Cor

    Thursday, April 9, 2015 11:54 AM