Skip to content

Simple python daemon to control a fan via GPIO pins and a NPN transistor

License

Notifications You must be signed in to change notification settings

danielwujecki/rpi-fan-control

Repository files navigation

Raspberry Pi - Fan Control

Simple python daemon to control a fan via GPIO pins and a NPN transistor based on the CPU temperature.

Hardware Setup

Installation

Via docker-compose

  • Just run docker-compose up -d

Via systemd unit

  • Python version used is 3.8
  • Dependencies can be installed with: apt install python3-rpi.gpio
  • To setup the daemon I recommend to:
    1. Create a new user: sudo useradd -m fancontrol
    2. Lock the user, so one can not login with it: sudo passwd -l fancontrol
    3. Allow new user to access gpio pins by adding to a group: sudo gpasswd -a fancontrol dialout
    4. Checkout the repository in new users home: cd /home/fancontrol && sudo -u fancontrol git clone https://github.com/danielgolf/rpi-fan-control.git
    5. Copy the systemd unit file: sudo cp /home/fancontrol/rpi-fan-control/rpi_fan_control.service /etc/systemd/system
    6. Reload systemd: sudo systemctl daemon-reload
    7. Activate and run the daemon/service: sudo systemctl enable --now rpi_fan_control.service
  • The /home/fancontrol/rpi-fan-control/src/cputemp.py script can be copied or symlinked to $HOME/.local/bin/cputemp

Configuration

In the main script rpi_fan_control.py are four variables for configuration

  • GPIO_PIN: Number of GPIO pin to control the fan
  • SLEEP_TIME: How long to sleep between each cpu temp check
  • CPU_TEMP_FAN_ON: Temperatur on which the fan is turned on
  • CPU_TEMP_FAN_OFF: Temperatur on which the fan is turned off



About

Simple python daemon to control a fan via GPIO pins and a NPN transistor

Resources

License

Stars

Watchers

Forks

Packages

No packages published