PWMFanService is a systemd-service which aims for minimal dependencies and CPU-usage by utilizing the pwm hardware of a Raspberry Pi to control a fan based on the temperature of the CPU. It is written in C# and has a minimal footprint.
The following list contains the used nuget packages for this service:
- Microsoft.Extensions.Hosting
- Microsoft.Extensions.Hosting.Systemd
- Iot.Device.Bindings
- System.Device.Gpio
I assume you already connected your fans power and ground cable to the Raspberry Pi.
Connect your fans pwm connector to pin 18.
Create a new directory for the files and change into it
mkdir pwmfanservice
cd pwmfanservice
Get the latest release be downloading it.
wget https://github.com/projectflx/pwmfanservice/releases/download/v1.0.0/PWMFanService.tar.gz
Extract the files
tar xvf PWMFanService.tar.gz
Change directory into the scripts folder, add execution permission and run the script with elevated rights.
cd ./Scripts
chmod +x install.sh
sudo ./install.sh
The install-script does automatically activate the device tree overlay for pwm on pin 18. You are free to reconfigure it to another pin, but keep in mind that the only pins supporting hardware pwm are pin 12, 13, 18 and 19.
Check the console output for additional information.
For building this project from the source code the only thing you need, is the .NET 6.0 SDK. Additional dependencies will be downloaded via nuget when restoring the project.
After downloading and unzipping the files into a directory of your choice, the only command you need to run within that directory is the following.
dotnet publish