ar51an / raspberrypi-fan-control

Raspberry Pi Adjust Fan Speed With Temperature [C - WiringPi - Pigpio - Noctua PWM Fan]
MIT License
36 stars 6 forks source link

Feature request: Configuration file #1

Closed nztvar closed 2 years ago

nztvar commented 2 years ago

Hard coded values prevent easy customization, reuse. A configuration file could make the rpfc more flexible, and it is clearly a very popular project in the raspberry pi community. E.g. I need to control 3x Noctua A6 5v fans I am using to cool a small blade case (a slightly modified Cloudlet by C4Labs.com), and the temperature to be checked will need to be the highest reported by a monitoring script - probably a custom file location rather than /sys/class/thermal/thermal_zone0/temp.

Feature request: Read custom values for a setup from file:

Likely there are other values which could usefully be drawn from a configuration file, but these would be a great (for me!) start.

nztvar commented 2 years ago

Quick note: my first attempt to modify and recompile failed with errors, which are likely my fault though I did try to follow your and wiringPi's guidance.

ar51an commented 2 years ago

Updated the build cmd in readme, with gcc 10 in raspios bullseye the linked libraries order has changed. This should work: sudo gcc fan-control.c -o fan-control -lwiringPi -lsystemd

nztvar commented 2 years ago

This worked perfectly for me to compile with my hard-coded values. The only issue I see is, presumably, a circuit issue with the TACHO, which fan-control is reporting as 0.0 Hz. (I am using the circuit outlined on rpiforum with the 3.3v -> r1 2.2 ㏀ -> join ( fan green + GPIO 23 ).)

ar51an commented 2 years ago

I am still using this code on my RPI4 with Noctua fan for almost a year and half and it works fine. The issue you are facing is with the circuit (also take a look into noctua white paper, may be because you connected tacho through 3.3v) I connect fan directly to the 5v pin and pwm pin directly to the gpio without any circuit in between. I do not connect anything to the 3.3v. Main idea behind writing this code and using noctua pwm fan was to avoid any circuit, use hw pwm and utilize noctua fan's internal pull-up resistor.

Tacho pin code was written during development for testing purpose, it does not add any value in the final service for controlling fan speed (unless you want to utilize software pwm), that is why it is commented out in the final code.

Anyways I tested Tacho pin output right now and it is working fine. Fan should be running to see the tacho output. When fan is not running tacho output will be 0Hz. Also change the delay to 2 sec (WAIT = 2000) to get more accurate tacho output. tacho-output

ar51an commented 2 years ago

May be in some future release when I get time I might take a look into configuration file option. But it is low priority right now. The code I shared is very well documented and it should not be very hard to customize it according to a specific need.

nztvar commented 2 years ago

Yes, I figured out my circuit problem eventually - a case of not thinking clearly. The software works fine. And, like you, with a working solution it becomes a lower priority to add features.

ar51an commented 2 years ago

Added params.conf for configurable parameters. Instructions updated in readme. It is a very basic configuration file as long as you stick with the provided format, it will work fine. I did not add any extensive checks for trailing and leading spaces, it is going to increase binary size.

Edit: Configurable TACHO_ENABLED is available through params.conf from release v2.0