{"id":26689631,"url":"https://github.com/jonboh/raspi-fancontrol","last_synced_at":"2025-07-14T03:12:39.574Z","repository":{"id":281231097,"uuid":"944633891","full_name":"jonboh/raspi-fancontrol","owner":"jonboh","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-07T18:16:13.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-03T11:29:34.361Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonboh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-07T17:36:14.000Z","updated_at":"2025-03-07T18:16:16.000Z","dependencies_parsed_at":"2025-03-07T18:44:13.432Z","dependency_job_id":null,"html_url":"https://github.com/jonboh/raspi-fancontrol","commit_stats":null,"previous_names":["jonboh/raspi-fancontrol"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jonboh/raspi-fancontrol","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonboh%2Fraspi-fancontrol","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonboh%2Fraspi-fancontrol/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonboh%2Fraspi-fancontrol/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonboh%2Fraspi-fancontrol/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonboh","download_url":"https://codeload.github.com/jonboh/raspi-fancontrol/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonboh%2Fraspi-fancontrol/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265237323,"owners_count":23732509,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-26T14:47:08.153Z","updated_at":"2025-07-14T03:12:39.476Z","avatar_url":"https://github.com/jonboh.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RP Fan Control\n\nA simple temperature-based fan control utility specifically tailored for Raspberry Pi that regulates the fan speed using software Pulse-Width Modulation (PWM).\n\n## Features\n- Reads CPU temperature at configurable intervals.\n- Adjusts fan PWM based on a specified temperature-to-PWM mapping curve.\n\n## Requirements\n\n- Rust and Cargo (Rust's package manager) should be installed on your Raspberry Pi.\n- Any additional dependencies are managed with Cargo and specified in the `Cargo.toml` file.\n\n## Usage\n\nCompile and run the program with the following commands:\n\n```sh\ncargo build --release\n./target/release/rp_fancontrol [OPTIONS]\n```\n\n### Command Line Options\n\nBelow are the available command line options for customizing the behavior of the fan control:\n\n- `--temp_file` - Path to the file from which to read the temperature (default: `/sys/class/thermal/thermal_zone0/temp`).\n- `-i`, `--interval` - Interval, in milliseconds, for re-evaluating fan power (default: `5000`).\n- `-t`, `--temp` - Temperature value in the temp-to-PWM curve, use multiple times for different points (no default, must be specified).\n- `-p`, `--pwm` - PWM value corresponding to the `--temp` values in the temp-to-PWM curve, use multiple times for different points (no default, must be specified).\n- `--pwm_channel` - PWM channel to which the fan is connected (default: `2` (for`PWM2 == GPIO18`); other options are `0`, `1`, `3`).\n\n## Configuration\n\nUse `--temp` and `--pwm` to define the points in the temperature to PWM conversion curve. The number of `--temp` and `--pwm` points must agree and temperatures should be in increasing order, whereas PWM values should be non-decreasing.\n\nExample command using configuration options:\n\n```sh\n./target/release/rp_fancontrol --interval 5000 --temp 40.0 --temp 60.0 --pwm 0.0 --pwm 1.0 --pwm_channel 2\n```\n\nThis command sets the program to check temperature every 5000 milliseconds and to control the fan using PWM based on the defined temp-to-PWM curve.\n\n## As a systemd unit in NixOS\nI use this in a systemd unit in NixOS:\n```nix\n{\n  systemd.services.rp-fancontrol = {\n    enable = true;\n    description = \"RPi GPIO fan control service\";\n    after = [\"multi-user.target\"];\n    wantedBy = [\"multi-user.target\"];\n    serviceConfig = {\n      ExecStart = \"${pkgs.rp-fancontrol}/bin/rp-fancontrol --temp 40 --pwm 0 --temp 50 --pwm 0.5 --temp 60 --pwm 0.7 --temp 70 --pwm 1\";\n      Type = \"simple\";\n      Restart = \"always\";\n      RestartSec = \"5\";\n    };\n  };\n}\n```\nTo consume the package from the flake use:\n```nix\n{\n  inputs = {\n    # ... your other inputs\n   raspberry-pi-nix.url = \"github:nix-community/raspberry-pi-nix\";\n   raspi-fancontrol = {\n      url = \"github:jonboh/raspi-fancontrol\";\n    };\n  };\n  outputs = {self, ...}@inputs: {\n      nixosConfigurations = {\n        \"brick\" = inputs.nixpkgs.lib.nixosSystem {\n          system = \"aarch64-linux\";\n          specialArgs = {inherit self;};\n          pkgs = import inputs.nixpkgs {\n            system = \"aarch64-linux\";\n            overlays = [\n              (final: prev: {\n                # here you add raspi-fancontrol to your pkgs\n                raspi-fancontrol = self.inputs.raspi-fancontrol.packages.aarch64-linux.default;\n              })\n            ];\n          };\n          modules = [\n            inputs.raspberry-pi-nix.nixosModules.raspberry-pi\n            inputs.raspberry-pi-nix.nixosModules.sd-image\n            ./configuration.nix\n          ];\n        };\n      }\n    };\n}\n```\n\nIn addition in your `configuration.nix` you need to configure the PWM pins:\n```nix\n{\n  hardware.raspberry-pi.config = {\n    # see: https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README#L3880\n    pi5.dt-overlays = {\n      \"pwm,pin=12,func=4\" = {\n        enable = true;\n        params = {};\n      };\n      \"pwm,pin=18,func=2\" = {\n        enable = true;\n        params = {};\n      };\n    };\n  };\n}\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonboh%2Fraspi-fancontrol","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonboh%2Fraspi-fancontrol","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonboh%2Fraspi-fancontrol/lists"}