Skip to content

Latest commit

 

History

History
67 lines (49 loc) · 2.06 KB

README.md

File metadata and controls

67 lines (49 loc) · 2.06 KB

Orange Pi 5 Fan Control

This script written in C language reads the CPU temperature and adjusts the fan speed based on that information. Before the script can work, wiringOP needs to be downloaded and installed from Git to enable the use of GPIO pins. Additionally, the script needs to be compiled after it's downloaded.

Requirements

Installation

  1. Download wiringOP from Git:
git clone --branch next https://github.com/orangepi-xunlong/wiringOP.git
  1. Navigate to the wiringOP directory and run the installation command:
cd wiringOP
./build clean
./build
  1. Download the C script and save it to the directory of your choice.
git clone https://github.com/bastilmr/opi5-fan-control.git
  1. Compile the script using the following command:
gcc -o fan-control fan-control.c -lwiringPi
  1. Make the script executable:
chmod +x fan-control
  1. Add the script to your crontab to run at boot using the following command:
crontab -e
  1. Add the following line to your crontab to run the script at boot:
@reboot /path/to/fan-control

Be sure to replace /path/to/ with the actual path to the directory where the script is located.

Configuration

The script is configured by default to control the fan speed based on the CPU temperature. However, you can customize the configuration to your needs by changing the following variables in the script:

  • FAN_PIN: The GPIO pin where the fan is connected.
  • CPU_TEMP_FILE: The file that contains the CPU temperature.
  • MIN_TEMP: The minimum CPU temperature at which the fan runs at the minimum speed.
  • MAX_TEMP: The maximum CPU temperature at which the fan runs at the maximum speed.
  • MIN_PWM: The minimum fan speed.
  • MAX_PWM: The maximum fan speed.

In this example, the fan was connected to the 5V, Ground, and GPIO4_A3 (UART0_TX_M2) Pin of the Orange Pi 5.

Note

This script has been successfully tested on an Orange Pi 5. However, it should also work on other Orange Pi's.