Skip to content

How to control a PWM fan depending on CPU temperature on a Orange Pi Zero (H2+ / H3)

License

Notifications You must be signed in to change notification settings

tsurkan-av/Orange-Pi-H2-H3-Hardware-PWM-Fan

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OrangePi Zero (H2+, H3) Hardware PWM-Fan control

How to control a PWM fan depending on CPU temperature on a OrangePi Zero (H2+ / H3) directly from the harware pwm pin (without a transistor, diode and resistor)? The current settings keeps the temperature below 50 degrees Celsius.

OrangePi Zero

This solution requires Python - best with V 3.x or later. All examples are done with V 3.7

This was developed and tested on an OrangePi Zero. Most likely it will work on any H2+ and H3 chip solutions. The only thing to bare in mind is that you need to use PWM0 pin. On the OPi Zero (or on PC+) board this is the middle pin of the Debug TTL UART pins (the tree pins that stand alone next to the ethernet port).

Step 1: Make sure you run the most recent software

# sudo apt-get update && sudo apt-get dist-upgrade -y

Step 2: Install or update Python 3.7 or later

# python3 --version -->shows actual installed version(s)

# sudo apt-get install python3.7 -->installs Python3.7

The two most crucial third-party Python packages are setuptools and pip.

# command -v pip3 -->see if PIP for Python3 is installed

Step 3: Activate HW pwm on your OPi Zero

Edit /boot/armbianEnv.txt and add new line: overlays=pwm

# cd /boot

# nano armbianEnv.txt --> insert new line with overlays=pwm

Exit Nano with ControlX, y and Enter

# sudo reboot-->reboot the OPi

Step 4: Install OpiGPIO

# sudo pip3 install --upgrade OPi.GPIO

More info about OPi.GPIO is here: https://opi-gpio.readthedocs.io and here: https://github.com/rm-hull/OPi.GPIO

Step 5: Install WiringOP-Zero

# cd /root

# git clone https://github.com/xpertsavenue/WiringOP-Zero.git

# cd WiringOP-Zero

# chmod +x ./build

# sudo ./build

Test if successful:

# gpio readall

More info about WiringOP-Zero is here: https://github.com/xpertsavenue/WiringOP-Zero.

Step 6: Install PWM Fan

In my case I have bought a nocuta NF-A4x10 5V PWM fan https://noctua.at/en/products/fan/nf-a4x10-5v-pwm. Excellent piece of work.

OrangePi Zero

Connect:

YELLOW (VIN) to physical pin 4 (5V)

BLACK (GND) to physical pin 6 (GND)

BLUE (PWM) to middle pin of Debug TTL UART pins (3 standalone pins next to the Ethernet plug)

GREEN (RPM) will NOT be connected

OrangePi Zero

Step 7: Python program and autostart

Credits for this goes to https://www.instructables.com/PWM-Regulated-Fan-Based-on-CPU-Temperature-for-Ras/. To run the program automatically at startup, just use the bash script and autolaunch this bash script at startup within rc.local.

Copy launch_fan_ctrl.sh and fan_ctrl.py into /home (use FileZilla or similar)

Edit the /etc/rc.local file and add a new line before the "exit 0": sudo sh '/home/launch_fan_ctrl.sh':

# nano /etc/rc.local

add sudo sh '/home/launch_fan_ctrl.sh' as a new line before exit 0

Exit Nano with ControlX, y and Enter

# sudo reboot

done! 😄

About

How to control a PWM fan depending on CPU temperature on a Orange Pi Zero (H2+ / H3)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 95.4%
  • Shell 4.6%