Git Product home page Git Product logo

opifancontrol's Introduction

opifancontrol

A simple PWM fan controller for Orange Pi boards (Only tested on an Orange Pi 5 Plus).

ℹī¸ This is for fans connected through standard GPIO header pins. Orange Pi 5 Plus has a dedicated fan header, which can be configured by following the manual.

Features

  • Runs as a systemd service
  • Automatically control the speed of a PWM fan based on the temperature of the CPU
  • Configurable thresholds for fan speed and temperature
  • Ramp up and ramp down delays to avoid rapid on/off switching of the fan

Hardware Setup

I am currently using:

For the Orange Pi 5 Plus, I connect the fan to the 5V and GND pins and the PWM wire to the physical pin 5 (wPi pin 2) on the GPIO header

Pins to connect fan to on the Orange 5 Plus board

Software Installation

Prerequisites

Installed the wiringOP library. Check the installation instructions.

Install via script

Run the following command to install the fan controller:

# Run again with sudo if you get permission errors
curl -sSL https://raw.githubusercontent.com/jamsinclair/opifancontrol/main/install.sh | bash

Install manually

Install the fan controller manually.
  1. Copy the opifancontrol.sh script to /usr/local/bin/ and make it executable:
cp opifancontrol.sh /usr/local/bin/opifancontrol
chmod +x /usr/local/bin/opifancontrol
  1. Copy the opifancontrol.conf file to /etc/:
cp opifancontrol.conf /etc/
  1. Copy the opifancontrol.service file to /etc/systemd/system/:
cp opifancontrol.service /etc/systemd/system/
  1. Enable the service:
systemctl enable opifancontrol.service

Configuration

The configuration file is located at /etc/opifancontrol.conf. The default configuration is:

# The GPIO pin to use for the fan. This is the wPi pin number, not the physical pin number.
# You can find the wPi pin number by running `gpio readall` on the Orange Pi.
FAN_GPIO_PIN=2

# TEMP_LOW, TEMP_MED, TEMP_HIGH are in degrees Celsius
# FAN_LOW, FAN_MED, FAN_HIGH are in percent of max fan speed, max 100.
# The fan will only be turned on if the temperature is above TEMP_LOW.
TEMP_LOW=55
FAN_LOW=50
TEMP_MED=65
FAN_MED=75
TEMP_HIGH=70
FAN_HIGH=100

# How frequently, in seconds, to poll the temperature data
TEMP_POLL_SECONDS=2

# To avoid rapid on/off switching, the fan will delay switching back on if it was recently turned off.
RAMP_UP_DELAY_SECONDS=15
# The ramp down delay is how long the fan will stay on after the temperature drops below the threshold.
RAMP_DOWN_DELAY_SECONDS=60

# The PWM range and clock are used to control the fan speed. You shouldn't need to change these unless you know what you're doing.
# Assumes the CPU fan runs at 25kHz.
PWM_RANGE=192
PWM_CLOCK=4

# Set to true to enable debug logging of fan speed changes.
DEBUG=false

Uninstallation

To uninstall the fan controller, first stop and disable the service:

systemctl stop opifancontrol.service
systemctl disable opifancontrol.service

Then remove the files:

rm /usr/local/bin/opifancontrol.sh
rm /etc/opifancontrol.conf
rm /etc/systemd/system/opifancontrol.service

License

This project is licensed under the MIT License - see the LICENSE file for details.

opifancontrol's People

Contributors

jamsinclair avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

opifancontrol's Issues

Orange pi5

Hi! Great job. But I only have an orange pi 5. Does it work for it?
Have a nice day

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤ī¸ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.