Skip to content

Repository files navigation

Disk SMART Fan Controller

App icon

A small, self-contained Windows application that reads a selected USB hard drive's SMART temperature and controls an HC530/CH340 one-channel USB relay for a cooling fan. It identifies the drive by SMART identity instead of drive letter, and identifies only a physical CH340 relay—Bluetooth virtual COM ports are ignored.

中文说明:这是一个给 USB 硬盘盒配风扇用的轻量 Windows 程序。它依据 SMART 温度自动控制 HC530 单路继电器,不依赖盘符,也不会把某一次检测到的 COM 口写死。

What it does

  • Three fan modes: Auto, Always on, and Always off.
  • Adjustable start/stop thresholds with validation: the start temperature must be higher than the stop temperature.
  • Hysteresis control: for example, start at 45 °C and stop below 40 °C.
  • Automatically discovers a physical CH340 relay when the application starts, then keeps that COM port for the current run. The next launch detects again.
  • Reads SMART information from the configured disk and shows temperature, model, serial number, health, power-on hours, device name, and the last read time.
  • Saves temperature readings with second-level timestamps in CSV, retains the most recent seven calendar days, and migrates older sidecar logs into %LOCALAPPDATA%\\DiskFanControl\\temperature-log.
  • Displays 1/3/10/30 minute and 1/3/6/24 hour history on a real-time-axis trend chart, including records made before the last restart.
  • Closing the window minimizes it to the system tray. Use Exit in the window or tray menu to stop the controller and release the relay.
  • On first launch, registers a DiskFanControl Task Scheduler task that starts the controller minimized after the current user logs in. It runs with the same elevated privileges required for SMART access and updates its executable path when the app is launched from a new location.
  • Starts a built-in, lightweight LAN web-debug page on port 18090. It can view SMART and relay status, refresh SMART, select a fan mode, and save temperature thresholds.

Hardware and software

  • Windows 10 or newer.
  • An HC530 (or compatible) CH340 one-channel USB serial relay. It uses 9600 8N1 and the direct relay commands documented for the board.
  • A USB hard-drive enclosure whose SMART data can be read by smartctl.
  • The CH340 Windows driver must be installed. No separate .NET or Python installation is required for a published build.

The program requests administrator privileges because USB pass-through SMART reads commonly require elevation.

Use

  1. Connect the HC530 relay and fan. For a normally-open circuit, wire the fan through COM and NO.
  2. Run DiskFanControl.exe as administrator.
  3. On the first successful SMART read, confirm the displayed target drive. The application stores its SMART identity in config.json.
  4. Select a mode and save start/stop temperatures. In Auto mode, saving thresholds immediately re-evaluates the fan state.

config.json is intentionally local runtime state and is not versioned. Keep relayPort as AUTO for portable deployment; the program detects the HC530 once per launch and does not persist the detected COM port.

LAN web debugging

Use the 网页调试地址 button in the desktop application or the tray-icon menu to display the exact address. Open that address from another device on the same LAN. No password or token is required, as requested for a trusted network.

The server listens on TCP port 18090 and adds one inbound rule for Private Windows networks only. It does not configure router port forwarding or expose the controller to the public Internet. Advanced settings are available in config.json: webDebugEnabled and webDebugPort.

Build from source

Install the .NET 9 SDK, then run:

dotnet restore
dotnet build -c Release
dotnet publish -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -o publish

The published folder includes smartctl.exe and its drive database. Launch the generated executable with administrator rights.

Data and safety notes

  • Temperature history is in %LOCALAPPDATA%\\DiskFanControl\\temperature-log, one temperature-YYYY-MM-DD.csv file per day. It is pruned to the latest seven calendar days.
  • Relay control switches only the USB relay. It cannot verify that a fan is physically connected or rotating.
  • A failed SMART read leaves the relay in its previous state and shows an error in the status area. Before unattended use, test both Always on and Always off with the actual fan connected.

Third-party component

SMART readings use the separately distributed smartctl.exe from smartmontools. See THIRD_PARTY_NOTICES.md and tools/LICENSE-smartmontools.txt for its GPL license and notices.

License

The Disk SMART Fan Controller source code is released under the MIT License. The bundled smartmontools files are separately licensed as described above.

About

Portable Windows app that controls a USB relay fan from HDD SMART temperature.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages