Setup & config options
Apache 2.4+ LAMP server
The game & not the islands
Setup & config options
North Atlantic : Macaronésia
Nine Azorean islands🚫 No ads & tracking
Most of the articles, descriptions and instructions written here are applicable to the most common Debian-based Linux derivatives. Depending on the respective operating system, there may be minor or major discrepancies.
This website is for educational purposes only. Please do not deploy anything in manufacturing plants.
No warranty or compensation is given for loss of data or hardware.
It should be also mentioned that this modest web server is hosted on a Raspberry Pi type 4B at home.
Caution Extreme attention and caution should be taken,
as improper handling may cause irreparable damage to the hardware !
The instructions may be useful for users where the CPU fan is constantly running at maximum speed and therefore causes a lot of noise. IBM / Lenovo Thinkpad notebooks cannot be controlled with LM sensors. With these notebooks »Thinkpad ACPI« helps. This also applies to at least some Dell notebooks. These can be controlled with the »i8kutils«, whereby automatic control is also directly integrated.
Pulse-width modulation (PWM) https://en.wikipedia.org/wiki/Pulse-width_modulation
There is no linearity between PWM and RPM (rounds per minute).
Requirements
apt install lm-sensors
sensors-detect
service kmod start
Example of outputs by the terminal command sensors
/ with one fan onboard only.
root@raspberry:/home/user# sensors
dell_smm-virtual-0 Adapter: Virtual device Processor Fan: 0 RPM CPU: +59.0°C Ambient: +54.0°C Other: +56.0°C GPU: +54.0°C BAT0-acpi-0 Adapter: ACPI interface in0: 16.90 V curr1: 1000.00 uA coretemp-isa-0000 Adapter: ISA adapter Package id 0: +59.0°C (high = +100.0°C, crit = +100.0°C) Core 0: +58.0°C (high = +100.0°C, crit = +100.0°C) Core 1: +59.0°C (high = +100.0°C, crit = +100.0°C) acpitz-acpi-0 Adapter: ACPI interface temp1: +59.5°C (crit = +99.0°C)
root@raspberry:/home/user# apt install fancontrol
Configuration of the fan control. Which fan(s) can be used ?
root@raspberry:/home/user# pwmconfig
The script now tries to determine which fan can be controlled. To do this, it tries to stop a fan for 5 seconds - if this has happened, confirm the following query with Y. It may happen that an error message is displayed and the fan should be switched off again. This should be done and the following query should be answered with Y again. Now it should work.
Once you have found a fan to be regulated, you can configure it as follows after the corresponding query to be confirmed with Y.
Confirm by Enter to accept the default path.
What should be the path to your fancontrol config file (/etc/fancontrol)
Note : the names of the all sensors and numbers vary from computer model to computer model.
Now press 1 + Enter to configure the corresponding fan. You will now be asked for the temperature sensor according to which the speed should be set.
fan output to configure, or other action:
1) hwmon4/pwm1
2) Change INTERVAL
3) Just quit
4) Save and quit
5) Show configuration
Now select the corresponding number and confirm it by Enter.
Select a temperature sensor as source for hwmon4/pwm1:
...
5) hwmon4/pwm1=hwmon4/temp1_input
...
9) None (Do not affect this PWM output)
You are now asked for the temperature at which the fan can switch off.
Now select a relatively low value according to the processor and cooler/fan combination. Pay attention to the manufacturer's specifications of the CPU !
Enter the low temperature (C)
at which the fan should be switched off (20):
Now the temperature at which the fan is to be brought up to its maximum speed is determined.
Here, too, pay attention to the manufacturer's specifications for the maximum processor temperature. It is best to specify a value that is somewhat lower.
Enter the high temperature (C)
at which the fan should be switched to full speed (60):
Now you are asked for the speed at which the fan should start to rotate as soon as the minimum temperature you set in the first step is exceeded. You can enter a value from 0 (fan off) to 255 (maximum speed).
In addition, you can decrease the fan speed in steps of 15 from 255-0 with the T key until you have found the corresponding value and confirmed it with T.
Enter the minimum PWM value (0-255)
at which the fan STARTS spinning (press t to test) (100):
Now you are asked for the speed at which the fan is still running. This describes the state that is reached when cooling down from a higher temperature has been successful.
Enter the minimum PWM value (0-255)
at which the fan STOPS spinning (press t to test) (100):
PWM value to use when the temperature is below the low temperature limit. Switch off, 0 RPM = 0.
Enter the PWM value (0-100) to use when the temperature
is below the low temperature limit (0):
PWM value (100-255) to use when the temperature is over the high temperature limit. Maximum fan speed e.g. approx. 5200 RPM = 255.
Enter the PWM value (100-255) to use when the temperature
is over the high temperature limit (255):
5) Show configuration
All settings OK ?
4) Save and quit
Example to possible settings in /etc/fancontrol
.
root@raspberry:/home/user# cat /etc/fancontrol
# Configuration file generated by pwmconfig, changes will be lost INTERVAL=10 DEVPATH=hwmon4= DEVNAME=hwmon4=dell_smm FCTEMPS= hwmon4/pwm1=hwmon4/temp1_input FCFANS= hwmon4/pwm1=hwmon4/fan1_input MINTEMP= hwmon4/pwm1=75 MAXTEMP= hwmon4/pwm1=80 MINSTART= hwmon4/pwm1=150 MINSTOP= hwmon4/pwm1=90 MINPWM= hwmon4/pwm1=0 MAXPWM= hwmon4/pwm1=255
Start the service and setup autostart
root@raspberry:/home/user# service fancontrol start
root@raspberry:/home/user# systemctl enable fancontrol
root@raspberry:/home/user# service fancontrol status
● fancontrol.service - fan speed regulator Loaded: loaded (/lib/systemd/system/fancontrol.service; enabled; vendor Active: active (running) since Wed 2021-12-22 18:50:12 CET; 15min ago Docs: man:fancontrol(8) man:pwmconfig(8) Process: 71087 ExecStartPre=/usr/sbin/fancontrol --check (code=exited, Main PID: 71190 (fancontrol) Tasks: 2 (limit: 9369) Memory: 3.2M CGroup: /system.slice/fancontrol.service ├─71190 /bin/bash /usr/sbin/fancontrol └─71797 sleep 10 Dez 22 18:50:12 Dell-Inspiron fancontrol[71190]: Controls hwmon4/fan1_input Dez 22 18:50:12 Dell-Inspiron fancontrol[71190]: MINTEMP=75 Dez 22 18:50:12 Dell-Inspiron fancontrol[71190]: MAXTEMP=80 Dez 22 18:50:12 Dell-Inspiron fancontrol[71190]: MINSTART=150 Dez 22 18:50:12 Dell-Inspiron fancontrol[71190]: MINSTOP=90 Dez 22 18:50:12 Dell-Inspiron fancontrol[71190]: MINPWM=0 Dez 22 18:50:12 Dell-Inspiron fancontrol[71190]: MAXPWM=255 Dez 22 18:50:12 Dell-Inspiron fancontrol[71190]: AVERAGE=1 Dez 22 18:50:12 Dell-Inspiron fancontrol[71190]: Enabling PWM on fans... Dez 22 18:50:12 Dell-Inspiron fancontrol[71190]: Starting automatic fan control
Some finetuning is required ?
root@raspberry:/home/user# service fancontrol stop
root@raspberry:/home/user# pwmconfig
root@raspberry:/home/user# service fancontrol start
22-Dec 2021
In the beginning it is advisable to observe the overall behaviour. The following string is re-executed every 5 seconds in terminal and the values are updated.
How can the functionality be tested? Perform an easy to make stress test. Take a file with a size of several Gigabytes and compile it into a zip-file or similar.
root@raspberry:/home/user# watch -n 5 sensors
Every 5,0s: sensors dell_smm-virtual-0 Adapter: Virtual device Processor Fan: 0 RPM CPU: +65.0°C Ambient: +58.0°C Other: +62.0°C GPU: +60.0°C
Exit by keys Crtl + C.
In a recent update of Raspberry Pi OS, there is a GPIO Fan option in the Performance Options of the RPi configuration GUI. Click on image to enlarge the GPIO diagramm.
Fan's red wire to GPIO pin ⑧ (GPIO 14 TXD)
Fan's black wire to GPIO pin ⑥ (ground, 0V).
Enable with raspi-config
in (4) Performance Options => (P4) Fan.
Temperature is controlled via actual firmware and will throttle the clock speed at 80°C. A future firmware update may change that. So then, the value may not be the same in the future.
When a fan is set as an exhaust fan, the idea is to expel hot air away from the heatsink / processor to pull off excess heat. If you want the fan to run permanently, just use pins ④ and ⑥ without enabling the option (P4) fan behaviour in the Performance Options.
root@raspberry:/home/user# watch -n 15 sensors
Every 15,0s: sensors cpu_thermal-virtual-0 Adapter: Virtual device temp1: +50.6°C
Exit by keys Crtl + C.
22-Dec 2021
Updated 26-Dec 2021