C
C#2mo ago
Joshman1412

does anyone know why my program cant find my cpu temps or my motherboard 12v rail readings

22 Replies
❤RieBi&❤
❤RieBi&❤2mo ago
$code
MODiX
MODiX2mo ago
To post C# code type the following: ```cs // code here ``` Get an example by typing $codegif in chat For longer snippets, use: https://paste.mod.gg/
Joshman1412
Joshman1412OP2mo ago
@❤RieBi&❤ its too long for that
Joshman1412
Joshman1412OP2mo ago
BlazeBin - txyfrknlqiit
A tool for sharing your source code with the world!
canton7
canton72mo ago
What's the actual problem with it? Why do you think that it fails?
Joshman1412
Joshman1412OP2mo ago
Because I get 0 degrees cpu temp and 0 12v rail voltage
canton7
canton72mo ago
Have you thought about asking the authors of LibreHardwareMonitor?
Joshman1412
Joshman1412OP2mo ago
No do I just go on the GitHub page for that
canton7
canton72mo ago
Start by searching the existing discussions and issues on their github project Whittle your code down to the minimum which reproduces the problem: you don't need anything except GetCPUTemperature really And do debug that a bit: you return 0 if you don't find any CPU hardware, or don't find any temperature sensors on the cpu, so find out whihc bit isn't working as you expect There's also this bit from the README:
Some sensors require administrator privileges to access the data. Restart your IDE with admin privileges, or add an app.manifest file to your project with requestedExecutionLevel on requireAdministrator.
Is that the problem?
Joshman1412
Joshman1412OP2mo ago
ok with admin it gets my cpu temps but not my 12v rail @canton7 do you know why this could be
canton7
canton72mo ago
I've never used that library, so no. What exactly is the problem: which line of code exactly doesn't do what you expect?
Joshman1412
Joshman1412OP2mo ago
private float GetVoltage()
{
foreach (var hardware in computer.Hardware)
{
if (hardware.HardwareType == HardwareType.Motherboard)
{
hardware.Update();
foreach (var sensor in hardware.Sensors)
{
if (sensor.SensorType == SensorType.Voltage)
{
return sensor.Value ?? 0;
}
}
}
}
return 0; // Return 0 if no sensor found
}
}
private float GetVoltage()
{
foreach (var hardware in computer.Hardware)
{
if (hardware.HardwareType == HardwareType.Motherboard)
{
hardware.Update();
foreach (var sensor in hardware.Sensors)
{
if (sensor.SensorType == SensorType.Voltage)
{
return sensor.Value ?? 0;
}
}
}
}
return 0; // Return 0 if no sensor found
}
}
canton7
canton72mo ago
Which line doesn't do what you expect? Do you not find any hardware? No motherboard hardware? No motherboard sensors? No voltage sensors? Find a voltage sensor, but it doesn't have a value? Etc etc
Joshman1412
Joshman1412OP2mo ago
it just gives me 0 its a winsform program so i dont know how view the output of this
private void LogAllSensors()
{
foreach (var hardware in computer.Hardware)
{
hardware.Update(); // Update hardware data
Console.WriteLine($"Hardware: {hardware.Name}");

foreach (var sensor in hardware.Sensors)
{
Console.WriteLine($"\tSensor: {sensor.Name}, Type: {sensor.SensorType}, Value: {sensor.Value}");
}

foreach (var subHardware in hardware.SubHardware)
{
subHardware.Update();
Console.WriteLine($"\tSubhardware: {subHardware.Name}");

foreach (var sensor in subHardware.Sensors)
{
Console.WriteLine($"\t\tSensor: {sensor.Name}, Type: {sensor.SensorType}, Value: {sensor.Value}");
}
}
}
}
private void LogAllSensors()
{
foreach (var hardware in computer.Hardware)
{
hardware.Update(); // Update hardware data
Console.WriteLine($"Hardware: {hardware.Name}");

foreach (var sensor in hardware.Sensors)
{
Console.WriteLine($"\tSensor: {sensor.Name}, Type: {sensor.SensorType}, Value: {sensor.Value}");
}

foreach (var subHardware in hardware.SubHardware)
{
subHardware.Update();
Console.WriteLine($"\tSubhardware: {subHardware.Name}");

foreach (var sensor in subHardware.Sensors)
{
Console.WriteLine($"\t\tSensor: {sensor.Name}, Type: {sensor.SensorType}, Value: {sensor.Value}");
}
}
}
}
to find the sensor i dont know if it finds it
canton7
canton72mo ago
Please read what I'm asking. Don't just ignore it Debug your code. Understand what it's doing. Use the debugger, or even Console.WriteLine
Joshman1412
Joshman1412OP2mo ago
the whole part ig it just isnt getting me the voltage where do i see the output because in output window in visual studio theres nothing about it
canton7
canton72mo ago
No, "the whole part" doesn't answer my question. Which specific bit of the code isn't doing what you expect? I listed a few options Console.WriteLine normally logs to the Output pane. Try Debug.WriteLine
Joshman1412
Joshman1412OP2mo ago
that gives me errors
canton7
canton72mo ago
So fix them
Joshman1412
Joshman1412OP2mo ago
debug doesnt exist
canton7
canton72mo ago
Yes it does. You might need to add a using statement. Ctrl+. on the squiggled code to give you options
Joshman1412
Joshman1412OP2mo ago
Hardware: ASUS PRIME B550M-A WIFI II Subhardware: Nuvoton NCT6798D Sensor: Fan #1, Type: Control, Value: 39.607845 Sensor: Fan #2, Type: Control, Value: 39.607845 Sensor: Fan #3, Type: Control, Value: 67.84314 Sensor: Fan #4, Type: Control, Value: 60 Sensor: Fan #5, Type: Control, Value: 60 Sensor: Fan #6, Type: Control, Value: 100 Sensor: Fan #7, Type: Control, Value: 100 Sensor: Vcore, Type: Voltage, Value: 0.504 Sensor: Voltage #2, Type: Voltage, Value: 0.99200004 Sensor: AVCC, Type: Voltage, Value: 3.3920002 Sensor: +3.3V, Type: Voltage, Value: 3.2800002 Sensor: Voltage #5, Type: Voltage, Value: 1.008 Sensor: Voltage #6, Type: Voltage, Value: 0.808 Sensor: Voltage #7, Type: Voltage, Value: 0.99200004 Sensor: 3VSB, Type: Voltage, Value: 3.3920002 Sensor: VBat, Type: Voltage, Value: 3.328 Sensor: VTT, Type: Voltage, Value: 0.90400004 Sensor: Voltage #11, Type: Voltage, Value: 0.4 Sensor: Voltage #12, Type: Voltage, Value: 0.4 Sensor: Voltage #13, Type: Voltage, Value: 1.0400001 Sensor: Voltage #14, Type: Voltage, Value: 0.984 Sensor: Voltage #15, Type: Voltage, Value: 0.984 Sensor: Temperature #1, Type: Temperature, Value: 38.5 Sensor: Temperature #2, Type: Temperature, Value: 36 Sensor: Temperature #3, Type: Temperature, Value: 26.5 Sensor: Temperature #4, Type: Temperature, Value: 36 Sensor: Temperature #5, Type: Temperature, Value: 36 Sensor: Temperature #6, Type: Temperature, Value: 27 Sensor: Fan #1, Type: Fan, Value: 1245.3875 Sensor: Fan #2, Type: Fan, Value: 1104.7463 Sensor: Fan #3, Type: Fan, Value: 0 Sensor: Fan #4, Type: Fan, Value: 0 Sensor: Fan #5, Type: Fan, Value: 0 Sensor: Fan #6, Type: Fan, Value: 0 Sensor: Fan #7, Type: Fan, Value: 0 i dont think it can find it although it shows up in hw monitor but not librehardware monitor
Want results from more Discord servers?
Add your server