Skip to content

theautomatist/ATtiny85-Fan-Controller

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ATtiny85 USB Fan PWM Controller

A compact USB-to-PWM fan controller built on the ATtiny45/85 and V-USB. It was created for GPU passthrough systems where the host (e.g., Proxmox) cannot read GPU temperature, but a VM can. The USB device is passed through to the VM, which then sets the fan speed based on GPU temperature.

Why this exists

When a GPU is passed through to a virtual machine, the host often has no access to the GPU sensors. That makes fan control on the host impossible. This project adds a small, low-cost USB fan controller so the VM can read the GPU temperature and drive the fan directly.

How it works

  1. The ATtiny enumerates as a USB CDC (virtual serial) device via V-USB.
  2. The VM sends a PWM percentage (0-100).
  3. The ATtiny outputs a 25 kHz PWM signal to a 4-pin fan. A value of 0 turns the fan off.

Features

  • Software-only USB stack (V-USB) with CDC serial interface.
  • Simple serial protocol: send a number and a carriage return.
  • Compatible with ATtiny45/85.
  • Linux works out-of-the-box; Windows needs a driver.

Hardware

Simple schematic for the ATtiny85 fan controller

Simple schematic for the ATtiny85 fan controller.

Components used for the controller

Components used for the controller.

Assembled controller board

Assembled controller board.

Enclosure for the controller board

3D-printed enclosure for the controller board.

Pin usage (ATtiny85)

Signal ATtiny pin Notes
PWM PB1 (D1) 25 kHz PWM output to the fan
SWITCH PB0 (D0) Fan power gating
TACH PB2 (D2) Tach input (unused in current firmware)

Adapter

An adapter for NVIDIA Tesla cards is available as an STL: https://www.thingiverse.com/thing:5391731

Air duct adapter for NVIDIA Tesla cards

Air duct adapter for NVIDIA Tesla cards.

Firmware and tooling

The firmware uses the VUSB-AVR board package for the Arduino IDE and the V-USB CDC library to implement a USB serial interface.

Build and flash

  1. Open Arduino IDE.
  2. Install VUSB-AVR.
  3. Select Tools -> Board -> VUSB AVR -> VUSB-AVR.
  4. Select Tools -> CPU -> ATtiny85 (16.5 MHz internal).
  5. Connect your ISP programmer to the ICSP header.
  6. Select Tools -> Programmer and choose your ISP programmer.
  7. Use Tools -> Burn Bootloader to set the fuses.
  8. Open software/FanController.ino and click Upload.

If you build a hex file and want to flash it directly, use a command like:

avrdude -c usbasp -p t85 -U lfuse:w:0xe1:m -U hfuse:w:0xdd:m -U efuse:w:0xff:m -U flash:w:FanController.hex

Usage

On Linux the device usually appears as /dev/ttyACM0. Send a value from 0 to 100 and a carriage return:

printf "65\r" > /dev/ttyACM0

Windows users need to install the Digistump drivers.

Host-side control

Any script can drive the controller by sending the desired PWM percentage over the serial device. For GPU passthrough setups, a small Python script in the VM typically reads GPU temperature (e.g., via nvidia-smi) and adjusts the fan speed accordingly.

Notes

  • Tested on Linux only.

License

Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. See LICENSE.

About

This project is a compact USB-to-PWM fan controller based on the ATtiny85, built for GPU passthrough setups where the host cannot read GPU sensors. A VM reads GPU temperature and drives the fan via a USB CDC serial interface, enabling simple external temperature control.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages

  • C++ 100.0%