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 口写死。
- 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
DiskFanControlTask 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.
- 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.
- Connect the HC530 relay and fan. For a normally-open circuit, wire the fan through COM and NO.
- Run
DiskFanControl.exeas administrator. - On the first successful SMART read, confirm the displayed target drive. The application stores its SMART identity in
config.json. - 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.
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.
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 publishThe published folder includes smartctl.exe and its drive database. Launch the generated executable with administrator rights.
- Temperature history is in
%LOCALAPPDATA%\\DiskFanControl\\temperature-log, onetemperature-YYYY-MM-DD.csvfile 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.
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.
The Disk SMART Fan Controller source code is released under the MIT License. The bundled smartmontools files are separately licensed as described above.
