homebridge-pwm-fan
v1.1.0
Published
PWM-based fan control and RPM output plugin for Homebridge
Downloads
9
Readme
homebridge-pwm-fan
PWM-based fan control and RPM tachometer, plugin for Homebridge
Installation
- Install Homebridge using
npm install -g homebridge
- Install this plugin
npm install -g homebridge-pwm-fan
- Run
sudo pigpiod
after installing the pigpio library and Python - Update your configuration file - see below for an example
Wiring diagram
More information: How PC Fans Work
Example of a wiring diagram for a PC fan with three wires:
If there are four wires, wire the control wire to the PWM instead (leaving the fan power tied to the voltage rail) (untested). If you only have two wires, PWM fan speed control is possible but there is no feedback, no tachometer to read RPM (TODO: make the tachometer optional)
Note that the tachometer may output voltage equal to the supply rail. To power the fan on higher voltages, a logic level shifter would be needed to drop down the tachometer output to +3.3V suitable for Raspberry Pi GPIO input.
Configuration
accessory
: "PWMFan"name
: descriptive nametach_bcm
: Broadcom pin number of tachometermotor_bcm
: Broadcom pin number of motor control/powerfrequency
: PWM frequency in hertzdef_dutycycle
: default dutycycle on startup (0-255 = 0-100%)min_dutycycle
: minimum dutycycle, ignore attempts to set below (0-255 = 0-100%)
The given pin numbers should be the Broadcom (BCM) numbers, not physical. Tachometer readings may be inaccurate on 3-wire fans, especially at higher frequencies or lower duty cycles (fix is to use a 4-wire fan, with independent pulse-width control and fan power supply).
Example configuration:
"accessories": [
{
"accessory": "PWMFan",
"name": "Desk Fan",
"tach_bcm": 16,
"motor_bcm": 23,
"frequency": 1,
"def_dutycycle": 255,
"min_dutycycle": 0
}
]
This creates a Fan service, with characteristics: On, and RotationSpeed (get/set).
Implementation notes
Currently this plugin uses a Python helper script to access pigpiod, see pwmfanhelper.py
for reasons why and how this could be improved to use native Node.js modules in the future
(patches welcome!).
License
MIT