You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28-38Lines changed: 28 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,42 +18,43 @@
18
18
<divalign="justify">
19
19
20
20
### Intro
21
-
Service to adjust RP4 PWM (Pulse Width Modulation) fan speed automatically based on CPU temperature. It will help in reducing fan noise and power consumption. It is written in C. **Main objective is to keep it fast and use minimum CPU and memory resources**.
21
+
Raspberry Pi fan-control service to adjust PWM fan speed automatically based on CPU temperature. It will help in reducing fan noise and power consumption. It is written in C. **Main objective is to keep it fast and use minimum CPU and memory resources**.
If you just want PWM fan On/Off based on CPU temperature. Connect fan's `PWM, ground and +5V wires` directly to the GPIO pins. Enable fan **either** from raspi-config **or** UI. Set the PWM pin and CPU temperature in the setup. Lowest temperature you can specify from setup is 60°C. This limit can be bypassed by editing `/boot/config.txt` manually. Search for `dtoverlay=gpio-fan` entry and change the `temp=60000`value to your desired temperature. Fan will start at the specified CPU temperature and it will stop 10°C below that. The downside is fan will run at full speed and bit noisy, specially if you are using an open RP4 case.
29
+
If you just want PWM fan On/Off based on CPU temperature. Connect fan's `PWM, ground and +5V wires` directly to the GPIO pins. Enable fan **either** from raspi-config **or** UI. Set the PWM pin and CPU temperature in the setup. Lowest temperature limit of 60°Ccan be bypassed by editing `/boot/firmware/config.txt` manually. Find `dtoverlay=gpio-fan` entry and change the `temp=60000` to the desired temperature. Fan will start at the specified CPU temperature and it will stop 10°C below that. The downside is fan will run at full speed and bit noisy, specially if you are using an open RP4 case.
30
30
<br/>
31
31
32
-
This service is specifically written for `Noctua 5V PWM` fan and `Raspberry Pi 4`. It may work for other PWM fans and RP models. You should know the intended fan's specifications, like max / min `RPM` and `target frequency`. Adjust these values in code/config and rebuild the binary (if needed). Raspberry Pi crystal oscillator clock frequency on RPi4B is 54MHz and on all earlier models it is 19.2MHz. `WiringPi` function `pwmSetClock` requires a divisor of clock frequency to set the target frequency of fan. The process is well documented in the fan-control source code.
32
+
This service is specifically written for `Noctua 5V PWM` fan and `Raspberry Pi 4`. It may work for other PWM fans and RP models. You should know the intended fan's specifications, like max / min `RPM` and `target frequency`. Adjust these values in code/config and rebuild the binary (if needed).
33
33
<br/>
34
34
35
-
I connected Noctua fan wires directly to the RP4 GPIO pins. It's been almost 2 years without any issue, your mileage may vary. If your fan does not support PWM or you want to safeguard hardware **either** build your own circuit **or** buy a pre-built PCB with transistor and diode like [EZ RP Fan Controller](https://www.tindie.com/products/jeremycook/ez-fan2-tiny-raspberry-pi-fan-controller/).
36
-
***WARNING: I accept no responsibility if you damage your Raspberry Pi or fan.***
35
+
I connected Noctua fan wires directly to the RP4 GPIO pins. It's been almost 3 years without any issue, your mileage may vary. If your fan does not support PWM or you want to safeguard hardware **either** build your own circuit **or** buy a pre-built PCB with transistor and diode like [EZ RP Fan Controller](https://www.tindie.com/products/jeremycook/ez-fan2-tiny-raspberry-pi-fan-controller/).
36
+
37
+
> `⚠️`**WARNING:*****I accept no responsibility if you damage your Raspberry Pi or fan.***
> |`NF-A4x10 5V PWM Fan`|`Raspberry Pi 4 Model B`|`raspios-bookworm-arm64-lite`|`79`|
43
45
#
44
46
45
47
### Hardware Prep
46
48
* The default noctua fan connector will not connect directly to GPIO header. You need to do some modifications. There are multiple options:
47
49
> **1 - Dupont Jumper Wires Male to Female:**
48
-
> Noctua's existing wire is pretty long. Get short jumper wires somewhere between 2-4" long. Male part of jumper wire will connect to Noctua connector and Female part will connect to GPIO. This is what I used in the beginning for few months.
50
+
> Noctua's existing wire is pretty long. Get short jumper wires somewhere between 2-4" long. Male part of jumper wire will connect to Noctua connector and Female part will connect to GPIO. I used it for few months.
> This is the one I am using now, as shown in the preview. It is the cleanest option. It could be the most expensive option if you do not have all the tools. You need dupont Female pin connectors, crimping tool, wire cutter/stripper, heat shrink tube/heat gun **or** dupont connector housing.
52
-
> You can **either** buy connectors and housing kit **or** buy dupont connectors separately. Better options for dupont connectors are `Molex Crimp Terminals Series: 70058 Part No: 16020098` or `Harwin Series: M20 Part No: 1180042`. I used Molex connectors. For crimping I used IWISS `IWS-2820` crimping tool. Cover these connectors with **either** heat shrink tube (I used 3.00mm diameter tube) **or** dupont connector housing.
53
-
> If you go with this route. You have to cut the noctua fan wire to the required length. **Make sure you calculate required wire length properly before cutting**. If you cut it too short you will end up inserting wire joints. Strip wires (practice some stripping on the unused end). Attach dupont connectors to the stripped wires, crimp them with crimpping tool. Add heat shrink tubes to the connectors and shrink them with heatgun or attach connector housing.
54
-
53
+
> It is the cleanest option, as shown in the preview. You need dupont Female pin connectors, crimping tool, wire cutter & stripper, heat-shrink-tube & heat-gun **or** dupont connector housing.
54
+
> Better options for dupont connectors are `Molex Crimp Terminals Series: 70058 Part No: 16020098` or `Harwin Series: M20 Part No: 1180042`. I used Molex connectors and IWISS `IWS-2820` crimping tool. Cover these connectors with **either** heat shrink tube (3.00mm diameter tube) **or** dupont connector housing.
55
+
55
56
> **3 - Use Wires from Old Fan:**
56
-
> If you have some old fan laying around that has dupont connector wires and you have no plan of using it. Cut the wires from that fan, cut the Noctua connector and do some wire joining. Noctua fan comes with 4 OmniJoin adaptors, you can use them as well for joining wires.
57
+
> If you have some old unused fan laying around that has dupont connector wires. Cut the wires from that fan, cut the Noctua connector and do some wire joining. Noctua fan's OmniJoin adaptorscan be used for joining wires.
57
58
58
59
* Complete specification of Noctua fan is available at [Noctua Whitepaper](https://noctua.at/pub/media/wysiwyg/Noctua_PWM_specifications_white_paper.pdf). Details of Raspberry Pi GPIO pin layout is available at [GPIO Pinout](https://pinout.xyz/). Screenshots attached for quick reference.
59
60
@@ -70,19 +71,19 @@ I connected Noctua fan wires directly to the RP4 GPIO pins. It's been almost 2 y
70
71
|Blue PWM Signal |Physical Pin 12|
71
72
|Green RPM Signal|Physical Pin 16|
72
73
73
-
Fan's PWM signal wire is connected to the RP4 `Physical/Board pin 12 - GPIO/BCM pin 18`. This fan-control code uses GPIO 18 as default. There are 4 pins on RP4 that support hardware PWM `GPIO 12/13/18/19`. If you are going to use a different GPIO pin make sure you change the `PWM_PIN` in `params.conf` with the one you use.
74
-
The green tachometer wire on Noctua fan is used to calculate RPM. Connect the fan's RPM signal wire to the RP4 `Physical/Board pin 16 - GPIO/BCM pin 23`. By default, tacho output is disabled in `params.conf`. (refer to `Points to Note`)
74
+
Fan's PWM signal wire is connected to the RP4 `Physical pin 12 - GPIO pin 18`. This fan-control code uses GPIO 18 as default. There are 4 pins on RP4 that support hardware PWM `GPIO 12/13/18/19`. If you are going to use a different GPIO pin make sure you change the `PWM_PIN` in `params.conf` with the one you use.
75
+
The green tachometer wire on Noctua fan is used to calculate RPM. Connect the fan's RPM signal wire to the RP4 `Physical pin 16 - GPIO pin 23`. By default, tacho output is disabled in `params.conf`. (refer to `Points to Note`)
75
76
76
77
#
77
78
### Steps
78
-
#### ⮞ Install WiringPi
79
-
* Install `WiringPi C` library. You can download it from [WiringPi](https://github.com/WiringPi/WiringPi). Installation instructions are available at [Install](https://github.com/WiringPi/WiringPi/blob/master/INSTALL).
79
+
#### ❯ Install pigpio
80
+
* Install `pigpio C` library. You can download it from [pigpio](https://codeload.github.com/joan2937/pigpio/zip/refs/heads/master).
* Create folder `/opt/gpio/fan`. Copy `fan-control` and `params.conf` from the latest release under `build` folder to this newly created folder `/opt/gpio/fan`. Make sure both files are under the ownership of root and `fan-control` is executable. **Fan-control will work with default values without `params.conf`.**
87
88
88
89
> **Create folder:**
@@ -113,7 +114,7 @@ The green tachometer wire on Noctua fan is used to calculate RPM. Connect the fa
113
114
> **Check Journal Logs:**
114
115
> `sudo journalctl -u fan-control`
115
116
116
-
> **_NOTE:_**
117
+
> `ℹ️`**Note:**
117
118
> Default service starts fan-control early in the boot process. It works fine with `lite RaspiOS`. In case any issue or warning with fan-control startup at boot, you can modify the service to start late in the boot process. Edit `fan-control.service`. Uncomment `After=multi-user.target` and `WantedBy=multi-user.target`. Comment out `WantedBy=sysinit.target`. Save and reboot.
118
119
119
120
#
@@ -149,20 +150,9 @@ The green tachometer wire on Noctua fan is used to calculate RPM. Connect the fa
149
150
150
151
#
151
152
### Build
152
-
* Install `libsystemd-dev`. It is required if you are going to build fan-control source code. If you **do not** want journal logging at all from fan-control service you can skip `libsystemd-dev` package installation and remove journal logging from code, explained below.
153
-
> **Install Package:**
153
+
* Install `libsystemd-dev`. It is required for compiling fan-control source code.
154
154
> `sudo apt install libsystemd-dev`
155
155
156
-
* Binary is available in the release. If for any reason you want to rebuild.
* If you are not interested in journal logging. Comment out the include header `sd-journal.h` and journal logging lines starting with `sd_journal_print`
0 commit comments