{"id":18701689,"url":"https://github.com/daviehh/fanshim-cpp","last_synced_at":"2025-04-12T08:32:22.920Z","repository":{"id":207285917,"uuid":"200104895","full_name":"daviehh/fanshim-cpp","owner":"daviehh","description":"C++ code for the fan shim on raspberry pi","archived":false,"fork":false,"pushed_at":"2019-11-28T01:37:10.000Z","size":277,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-26T03:51:16.115Z","etag":null,"topics":["cpp","gpio","libgpiod","raspberry-pi"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daviehh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-08-01T19:01:52.000Z","updated_at":"2024-10-29T20:20:58.000Z","dependencies_parsed_at":"2023-11-15T02:46:41.633Z","dependency_job_id":null,"html_url":"https://github.com/daviehh/fanshim-cpp","commit_stats":null,"previous_names":["daviehh/fanshim-cpp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daviehh%2Ffanshim-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daviehh%2Ffanshim-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daviehh%2Ffanshim-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daviehh%2Ffanshim-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daviehh","download_url":"https://codeload.github.com/daviehh/fanshim-cpp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248540124,"owners_count":21121302,"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":["cpp","gpio","libgpiod","raspberry-pi"],"created_at":"2024-11-07T11:42:16.061Z","updated_at":"2025-04-12T08:32:17.906Z","avatar_url":"https://github.com/daviehh.png","language":"C++","readme":"# fanshim-cpp\n\n[![Build Status](https://travis-ci.com/daviehh/fanshim-cpp.svg?branch=master)](https://travis-ci.com/daviehh/fanshim-cpp)\n\nC++ driver code for the fanshim on raspberry pi using `libgpiod`\n\n[pimoroni link](https://shop.pimoroni.com/products/fan-shim)\n\n**Warning/disclaimer:**\n\n**very experimental code, for testing purposes only.**\n\n**[may not work at any time or even cause hardware damage (e.g. from causing the fan to be constantly running)].**\n\n**Only proceed if you know what the code is doing.**\n\n## Credits\n - official fanshim controller code https://github.com/pimoroni/fanshim-python\n - nlohmann/json https://github.com/nlohmann/json/ \n\n\n## Build\n - If not installed: get the `libgpiod-dev` library\n - Put the `json.hpp` file from https://github.com/nlohmann/json/releases in the same folder as the source code, tested with `3.7.0`\n - Compile with `clang++ fanshim_driver.cpp -o fanshim_driver -O3 -std=c++17 -lstdc++fs -lgpiodcxx` (may also work with `g++`)\n\n\n ## Example systemd service file\n Change `/path/to/compiled/binary` to the compiled binary path.\n \n ```\n [Unit]\nDescription=Fanshim C++ driver\n\n[Service]\nExecStart=/path/to/compiled/binary\nRestart=always\nRestartSec=5\n\n[Install]\nWantedBy=multi-user.target\n\n ```\n \n ## Configuration\n \n The configuration file is in `/usr/local/etc/fanshim.json`, example:\n ```json\n {\n    \"on-threshold\": 60,\n    \"off-threshold\": 50,\n    \"delay\": 10\n}\n ```\n \nWill use the value in the file to override the defaults, no need to specify all keys, just the ones you want to change. Keys used:\n \n - `on-threshold`/`off-threshold`: temperature, in Celsius, the threshold for turing on (off) the fan. Default to 60 and 50 respectively.\n \n - `delay`: in seconds, the program will wait this amount of time before checking the temperature again. Default to 10.\n \n - `budget`: an  integer n, the program will only turn on/off the fan if the temperature is consecutively above (below) the on (off) threshold for the last n temperature measurements. Defaults to 3.\n\n- `brightness`: an integer from 0 to 31, LED brightness, 0 means no LED (default).\n\n-  `blink`: an integer in [0, 1 , 2], where \n   - 0: no blink (default); \n   - 1: the LED will blink when the fan is not spinning; \n   - 2: the LED will \"breath\" when the fan is not spinning, the max brightness in this mode is `breath_brgt` (default 10).\n\n\n## Notes/todo\n\n - No button support (I think given the small size of the button, it'll be easier to force the fan on/off through software based on e.g. whether a certain file exists. Currently, the file is hard-coded as `/usr/local/etc/.force_fanshim`: fan will be on if this file exists)\n\n\n\n## Additional features\n \n - Will output current status to the file `/usr/local/etc/node_exp_txt/cpu_fan.prom` so that it can be used with external programs to monitor, e.g. node_exporter + prometheus + grafana:\n \n ![screen](https://raw.githubusercontent.com/daviehh/fanshim-cpp/master/rpi_monit_eg.png)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaviehh%2Ffanshim-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaviehh%2Ffanshim-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaviehh%2Ffanshim-cpp/lists"}