Jump to content

Tips & Techniques for Rem0o's FanControl software

This thread is for people who want to write about ways to use the FanControl software developed by Rem0o, which is described in the LTT thread linked below.  In message #2 I will post a .bat script that demonstrates one way to use the new .sensor feature provided by FanControl.  If you have ideas about how to use FanControl that you think are worth sharing, you may post them here.

 

Link to comment
Share on other sites

Link to post
Share on other sites

Here's a small .bat script that shows one way that people could use FanControl's new .sensor feature.  It's an infinite loop that uses the smartctl.exe utility of (free) Smartmontools to read the temperature of a usb-connected external drive, and when the temperature changes the new value is written to the .sensor file that FanControl periodically reads.  It's less than 20 lines of code (not counting the helpful comments).  The reason it may be useful is that FanControl is unable to read the temperature of usb-connected drives.

Quote

@echo off
rem  See the notes below for help using this .bat script.

 

set "EXTERNALDRIVE=D:"
set SMARTCTL=C:\Smartmontools\smartctl.exe
set SMARTATTRIBUTE=Temperature_Celsius
set FANCONTROLFOLDER=C:\fancontrol
set "SENSORFILENAME=External Drive"

 

setlocal enabledelayedexpansion
set PreviousT=999
rem  Infinite Loop:
for /L %%G in (0,0,0) do (
     rem  Use smartctl to read the drive's temperature:
     for /f "delims=" %%H in ('%SMARTCTL% -A %EXTERNALDRIVE% ^| findstr /R %SMARTATTRIBUTE%') do set "Line=%%H"
     set "Temperature=!Line:~87,2!"
     rem  If the temperature changed, write it to the .sensor file:
     if !Temperature! NEQ !PreviousT! (
          echo !Temperature!>"%FANCONTROLFOLDER%\%SENSORFILENAME%.sensor"
          set /A "PreviousT=Temperature"
     )
     rem  Wait 30 seconds before rereading the drive temperature:
     TIMEOUT /T 30 >nul
)
EXIT /B
===============================
NOTES
You must edit the 5 variables (constants) at the beginning,
to match your system and preferences!
1. In my system, drive D is the external drive.  If your drive doesn't have a volume label defined, you could use a device label instead; see the smartctl documentation webpage.
2. The path and filename of the Smartmontools' smartctl.exe utility.
3. Temperature_Celsius is the name that smartctl reports for my external drive's temperature attribute, according to the "smartctl -A D:" command.
4. The path to where the FanControl software is located.
5. The filename you choose for the .sensor file is what FanControl will display as the name of the sensor.

Except for the name of the .sensor file, don't use spaces in paths or filenames or the temperature attribute.  This .bat would need to be modified slightly to allow spaces.

The current version of FanControl (v37) requires the .sensor file to exist before FanControl is started. So if you start this .bat script and FanControl automatically using Windows Task Scheduler tasks, you may want to put a short startup delay in the FanControl task's definition.  Or you may want to modify this .bat so it will create the .sensor file and then start FanControl.  Or you could manually create the .sensor file by hand, once, as I did... an empty file with the desired filename.

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×