Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read HardDisk Temperature?

Is it possible to see the Harrdisk temperature with somekind of S.M.A.R.T API or anything like that?

i just want the temp, nothing else in C#

like image 409
MMM Avatar asked Nov 10 '11 12:11

MMM


People also ask

Is 50 degrees Celsius hot for a HDD?

The operating temperature range for most Seagate hard drives is 5 to 50 degrees Celsius. A normal PC case should provide adequate cooling.

Is 45 degrees hot for HDD?

You want to make sure your hard drives are operating within the range of 77- to 133-degrees Fahrenheit (25- to 45-degrees Celsius). This is the normal operating temperature range that will ensure you get the maximum life out of your hard drives.

Is 40c too hot for HDD?

Reputable. QSV : A temperature of around 40 C is perfect for a HDD. Thats where they live longest.

What is normal temperature for HDD?

What is the optimal temperature for hard disk drive operation? Most hard drive manufacturers specify a normal operating temperature between 0 °C to 60°C (32°F to 140°F).


2 Answers

Here is code snippet from this article Hope it helps

//S.M.A.R.T.  Temperature attribute
const byte TEMPERATURE_ATTRIBUTE = 194;

public List<byte> GetDriveTemp()
{
    var retval = new List<byte>();
    try
    {
        ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\WMI", "SELECT * FROM MSStorageDriver_ATAPISmartData");
        //loop through all the hard disks
        foreach (ManagementObject queryObj in searcher.Get())
        {
            byte[] arrVendorSpecific = (byte[])queryObj.GetPropertyValue("VendorSpecific");
            //Find the temperature attribute
            int tempIndex = Array.IndexOf(arrVendorSpecific, TEMPERATURE_ATTRIBUTE);
            retval.Add(arrVendorSpecific[tempIndex + 5]);
        }
    }
    catch (ManagementException err)
    {
        Console.WriteLine("An error occurred while querying for WMI data: " + err.Message);
    }
    return retval;
}
like image 136
Stecya Avatar answered Oct 17 '22 19:10

Stecya


use VMI and MSStorageDriver_ATAPISmartData to get VendorSpecific byte array and 115 byte number is temperature. Why 115? More here.

Code partly generated with VMI Code Creator

ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\WMI",
"SELECT * FROM MSStorageDriver_ATAPISmartData");

foreach (ManagementObject queryObj in searcher.Get())
{
   if (queryObj["VendorSpecific"] != null)
   {
       byte[] arrVendorSpecific = (byte[])(queryObj["VendorSpecific"]);
       string temp = arrVendorSpecific[115].ToString();
    }
 }
like image 41
Renatas M. Avatar answered Oct 17 '22 21:10

Renatas M.