From 63502f69698dd92f8327236c86b5bdb02fff90e4 Mon Sep 17 00:00:00 2001 From: Zykino Date: Thu, 2 Apr 2020 23:01:50 +0200 Subject: [PATCH] Add a Readme and prepare the push to crates.io --- Cargo.toml | 12 +++++---- README.md | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/fan/pwm.rs | 2 +- 3 files changed, 75 insertions(+), 6 deletions(-) create mode 100644 README.md diff --git a/Cargo.toml b/Cargo.toml index 176d7c2..c4d82fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,13 +1,15 @@ [package] name = "tempi" version = "0.1.0" -authors = ["Zykino"] +authors = ["Zykino "] +description = "Control your Raspberry Pi's temperature with a fan." +license = "GPL-3.0-or-later" +keywords = ["temperature", "fan", "raspberry pi"] +categories = ["command-line-utilities"] +readme = "README.md" edition = "2018" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -confy = { git = "https://github.com/GoWebProd/confy" } #"0.4.0" # Will need something more than this version to have yaml support +confy = { git = "https://rust-cli.github.io/book/index.html" } #"0.4.0" # Will need something more than this version to have yaml support rppal = "0.11.3" -#serde_derive = "1.0.104" serde = { version = "1.0.104", features = ["derive"] } diff --git a/README.md b/README.md new file mode 100644 index 0000000..5cb0c34 --- /dev/null +++ b/README.md @@ -0,0 +1,67 @@ +# Tempi +Control your Raspberry Pi's temperature with a fan. + +## Description +This program control a GPIO pin depending on the temperature of your CPU. It is thought of as a way to regulate the CPU's temperature by connecting a fan to the GPIO and letting the program check the temperature at a regular interval in the background. + +## Installation +### From source +First you need to [install Rust]. Then you can do the Rust's standard installation procedure: +```sh +git clone https://zykino.net/gitea/zykino/Tempi.git +cd Tempi +cargo build --release +``` + +If you prefer to cross-compile from a non raspberry computer I followed the manual instructions at . Once build, transfert the binary to your target and test it. +```sh +scp target/arm-unknown-linux-gnueabihf/release/tempi pi@: +``` + +## Usage +To use the application you just have to start the `tempi` executable. If you want to use it on a daily basis, it is recommanded to start the application at logon or startup. + +## Configuration +The only way to configure `tempi` is with a configuration file. The configuration file is written in yaml, but if you don't know what it is, you can surely copy one of the examples below and twist the values as you like. + +By default `tempi` will control the pin 18 (physical 12) in an `Hysteresis` mode. The configuration file corresponding is the following: +```yaml +--- +check_interval: + secs: 10 + nanos: 0 +mode: + Hysteresis: # Either Hysteresis or Pwm ith th appropriate parameters + max_temperature: 70.0 + hysteresis: 10.0 + bcm_pin: 18 +verbosity_mode: Human # One of Human, Machine or Quiet +``` + +If you prefer using the `PWM` mode you first need to follow this instructions to [enable PWM on your Raspberry Pi]. It is also recommended to let [the members of the gpio group configure PWM] without being root. Then you can use and adapt the following configuration file: +```yaml +--- +check_interval: + secs: 10 + nanos: 0 +mode: + Pwm: + max_temperature: 70.0 + min_temperature: 60.0 + frequency: 1 # You should tweak this value depending on your fan and expected percentage of normal usage. + channel: Pwm0 +verbosity_mode: Human +``` + +## State of the project +I feel that this project is fully featured for what it is right now: a raspberry pi temperature controler. +If someone would create a circuit using a 5V PIN and a GPIO as switch, I would love to elaborate and test new cooling strategies. + +It is also still possible to support more boards and have a better output for logging/plotting on an other application. + +Code wise it is one of my first Rust projets so any hint on how to upgrade my code and the ergonomics of `tempi` is welcome. Including adding tests, better usage of error, understanding if I should use `embedded-hal`, ... +I also need to document the code and maybe expose an interface to use it as a library. + +[install Rust]: https://www.rust-lang.org/tools/install +[enable PWM on your Raspberry Pi]: https://docs.golemparts.com/rppal/0.11.2/rppal/pwm/#pwm-channels +[the members of the gpio group configure PWM]: https://docs.golemparts.com/rppal/0.11.2/rppal/pwm/#using-pwm-without-superuser-privileges-sudo diff --git a/src/fan/pwm.rs b/src/fan/pwm.rs index 2b05880..ecffe6f 100644 --- a/src/fan/pwm.rs +++ b/src/fan/pwm.rs @@ -25,7 +25,7 @@ impl Default for PwmConfig { PwmConfig { max_temperature: 70_f64, min_temperature: 60_f64, - frequency: 0.1_f64, + frequency: 1_f64, channel: Channel::Pwm0, } }