-
-
Notifications
You must be signed in to change notification settings - Fork 14
feat: fan control to cool down Solar Router #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f800614
chore(temperature): cleanup temperature_limiter_common.yaml
XavierBerger f1d8f59
feat(temperature): Add fan control
XavierBerger 7159f29
chore: update examples
XavierBerger 2d1f1b7
doc: update doc and add wiring diagram of fan controller
XavierBerger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # Temperature fan control | ||
|
|
||
| This package is designed to manage a fan with the objective to control the temperature of the solar router. | ||
| This module is reading the temperature from a `temperature limiter`. | ||
| The fan can be configured to start spinning as soon as the start temperature is reached and stop spinning when the measured temperature comes below the stop temperature. | ||
|
|
||
| ??? Note "More about the mechanism avoiding regulation bouncing" | ||
| The two thresholds regulation used here is named **hysteresis**. This mechanism avoids regulation bouncing. | ||
| See ***More details about hysteresis and Schmitt trigger*** in [temperature_limiter](temperature_limiter.md) page. | ||
|
|
||
|
|
||
| !!! danger "WARNING: Conduct some tests before letting the system regulate alone" | ||
| This fan control logic may have some bugs. It is strongly advised to validate the behaviour of your system carefully before letting the system working by its own. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| This package is not standalone. It relies on symbols provided by two other packages that must be included in your configuration: | ||
|
|
||
| - an `engine_*` package (e.g. `engine_1dimmer.yaml`) that provides the `activate` switch, | ||
| - a `temperature_limiter_*` package (e.g. `temperature_limiter_DS18B20.yaml`) that provides the `safety_temperature` sensor. | ||
|
|
||
| ## Cooling direction | ||
|
|
||
| The fan is meant to cool the object monitored by `safety_temperature`. Fan **on** when the temperature rises above `fan_start_temperature`, fan **off** when it falls below `fan_stop_temperature`. if you need the opposite behaviour, this package is not the right fit. | ||
|
|
||
| ## Threshold invariant | ||
|
|
||
| The two thresholds are coupled: `fan_start_temperature > fan_stop_temperature` is always enforced. If you change one of them to a value that would break the invariant, the other one is nudged automatically by 1 °C so a valid hysteresis is preserved: | ||
|
|
||
| - setting `fan_stop_temperature` to a value `>=` the current `fan_start_temperature` pushes `fan_start_temperature` to `fan_stop_temperature + 1`, | ||
| - setting `fan_start_temperature` to a value `<=` the current `fan_stop_temperature` pulls `fan_stop_temperature` to `fan_start_temperature - 1`. | ||
|
|
||
| You can therefore edit either value in any order without ever landing on an invalid configuration. | ||
|
|
||
| ## Wiring | ||
|
|
||
| The energy available on a pin of the ESP32 is not sufficient to directly power the fan. It is then required to add an additional circuit to use 5V or 12V with the fan. | ||
|
|
||
| The following schematic represents the wiring of the fan: | ||
|
|
||
| {width=400} | ||
|
|
||
| ## Configuration | ||
|
|
||
| To use this package, add the following lines to your configuration file: | ||
|
|
||
| ```yaml linenums="1" | ||
| packages: | ||
| fan_controller: | ||
| url: https://github.com/hacf-fr/Solar-Router-for-ESPHome/ | ||
| files: | ||
| - path: solar_router/temperature_fan_control.yaml | ||
| vars: | ||
| fan_control_pin: GPIO4 | ||
| ``` | ||
|
|
||
| ### Variables | ||
|
|
||
| | Variable | Required | Default | Description | | ||
| | ---------------------- | -------- | --------- | -------------------------------------------------------------------------------------------- | | ||
| | `fan_control_pin` | yes | — | GPIO pin driving the fan control circuit. | | ||
| | `fan_control_inverted` | no | `"False"` | Set to `"True"` if the driving circuit inverts the logic (e.g. active‑low transistor stage). | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # Contrôle du ventilateur | ||
|
|
||
| Ce package est conçu pour piloter un ventilateur afin de contrôler la température du routeur solaire. | ||
| Ce module lit la température fournie par un `temperature limiter`. | ||
| Le ventilateur peut être configuré pour démarrer dès que la température de démarrage est atteinte et s'arrêter lorsque la température mesurée passe sous la température d'arrêt. | ||
|
|
||
| ??? Note "Détails du mécanisme de régulation anti-rebond" | ||
| La régulation à deux seuils utilisée ici est appelée **hystérésis**. Ce mécanisme évite les oscillations de la régulation. | ||
| Voir ***Plus de détails sur l'hystérésis et le trigger de Schmitt*** sur la page [temperature_limiter](temperature_limiter.md). | ||
|
|
||
|
|
||
| !!! danger "ATTENTION : effectuez des tests avant de laisser le système réguler seul" | ||
| La logique de contrôle du ventilateur peut contenir des bugs. Il est fortement conseillé de valider soigneusement le comportement de votre système avant de le laisser fonctionner seul. | ||
|
|
||
| ## Prérequis | ||
|
|
||
| Ce package n'est pas autonome. Il repose sur des identifiants fournis par deux autres packages qui doivent être inclus dans votre configuration : | ||
|
|
||
| - un package `engine_*` (par exemple `engine_1dimmer.yaml`) qui fournit l'interrupteur `activate`, | ||
| - un package `temperature_limiter_*` (par exemple `temperature_limiter_DS18B20.yaml`) qui fournit le capteur `safety_temperature`. | ||
|
|
||
| ## Sens de régulation | ||
|
|
||
| Le ventilateur est destiné à refroidir l'élément surveillé par `safety_temperature`. Il se met en marche lorsque la température dépasse `fan_start_temperature` et s'arrête lorsqu'elle descend en dessous de `fan_stop_temperature`. Si vous avez besoin d'un fonctionnement inverse, ce paquet ne convient pas. | ||
|
|
||
| ## Invariant des seuils | ||
|
|
||
| Les deux seuils sont couplés : `fan_start_temperature > fan_stop_temperature` est garanti en permanence. Si vous modifiez l'un des deux à une valeur qui casserait cet invariant, l'autre est automatiquement ajusté de 1 °C pour préserver une hystérésis valide : | ||
|
|
||
| - fixer `fan_stop_temperature` à une valeur `>=` à l'actuel `fan_start_temperature` remonte `fan_start_temperature` à `fan_stop_temperature + 1`, | ||
| - fixer `fan_start_temperature` à une valeur `<=` à l'actuel `fan_stop_temperature` descend `fan_stop_temperature` à `fan_start_temperature - 1`. | ||
|
|
||
| Vous pouvez donc modifier l'un ou l'autre des seuils dans n'importe quel ordre sans jamais tomber sur une configuration invalide. | ||
|
|
||
| ## Câblage | ||
|
|
||
| L'énergie disponible sur une broche de l'ESP32 n'est pas suffisante pour alimenter directement un ventilateur. Il est donc nécessaire d'ajouter un circuit supplémentaire pour piloter un ventilateur en 5 V ou 12 V. | ||
|
|
||
| Le schéma suivant présente le câblage du ventilateur : | ||
|
|
||
| {width=400} | ||
|
|
||
| ## Configuration | ||
|
|
||
| Pour utiliser ce package, ajoutez les lignes suivantes à votre fichier de configuration : | ||
|
|
||
| ```yaml linenums="1" | ||
| packages: | ||
| fan_controller: | ||
| url: https://github.com/hacf-fr/Solar-Router-for-ESPHome/ | ||
| files: | ||
| - path: solar_router/temperature_fan_control.yaml | ||
| vars: | ||
| fan_control_pin: GPIO4 | ||
| ``` | ||
|
|
||
| ### Variables | ||
|
|
||
| | Variable | Obligatoire | Défaut | Description | | ||
| | ---------------------- | ----------- | --------- | --------------------------------------------------------------------------------------------------------------------- | | ||
| | `fan_control_pin` | oui | — | Broche GPIO qui pilote le circuit de commande du ventilateur. | | ||
| | `fan_control_inverted` | non | `"False"` | À mettre à `"True"` si le circuit de commande inverse la logique (par exemple étage à transistor actif à l'état bas). | | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| substitutions: | ||
| fan_control_inverted: "False" | ||
|
|
||
| number: | ||
| - platform: template | ||
| id: fan_stop_temperature | ||
| name: "Temperature to stop fan" | ||
| max_value: 99999 | ||
| initial_value: 40 | ||
| min_value: -273 | ||
| step: 1 | ||
| optimistic: True | ||
| mode: box | ||
| unit_of_measurement: "°C" | ||
| restore_value: true | ||
| # Enforce fan_start_temperature > fan_stop_temperature. | ||
| # If the user pushes stop to a value that would break the invariant, | ||
| # start is bumped just above it. | ||
| on_value: | ||
| then: | ||
| - if: | ||
| condition: | ||
| lambda: |- | ||
| return !isnan(id(fan_start_temperature).state) | ||
| && x >= id(fan_start_temperature).state; | ||
| then: | ||
| - number.set: | ||
| id: fan_start_temperature | ||
| value: !lambda 'return x + 1;' | ||
|
|
||
| - platform: template | ||
| id: fan_start_temperature | ||
| name: "Temperature to start fan" | ||
| max_value: 99999 | ||
| initial_value: 50 | ||
| min_value: -273 | ||
| step: 1 | ||
| optimistic: True | ||
| mode: box | ||
| unit_of_measurement: "°C" | ||
| restore_value: true | ||
| # Symmetric guard: if start is pulled below stop, stop is lowered. | ||
| on_value: | ||
| then: | ||
| - if: | ||
| condition: | ||
| lambda: |- | ||
| return !isnan(id(fan_stop_temperature).state) | ||
| && x <= id(fan_stop_temperature).state; | ||
| then: | ||
| - number.set: | ||
| id: fan_stop_temperature | ||
| value: !lambda 'return x - 1;' | ||
|
|
||
| interval: | ||
| # Trigger action every second | ||
| - interval: 1s | ||
| then: | ||
| - if: | ||
| condition: | ||
| switch.is_on: activate | ||
| then: | ||
| - script.execute: fan_control_check | ||
|
|
||
| script: | ||
| - id: fan_control_check | ||
| mode: single | ||
| then: | ||
| - lambda: |- | ||
| if ( isnan( id(safety_temperature).state ) ){ | ||
| // Can't read temperature. Turn fan on as a failsafe. | ||
| id(fan_control).turn_on(); | ||
| return; | ||
| } | ||
| if (id(safety_temperature).state >= id(fan_start_temperature).state) | ||
| { | ||
| id(fan_control).turn_on(); | ||
| return; | ||
| } | ||
| if (id(safety_temperature).state <= id(fan_stop_temperature).state) | ||
| { | ||
| id(fan_control).turn_off(); | ||
| } | ||
|
|
||
| output: | ||
| - id: fan_control | ||
| platform: gpio | ||
| pin: | ||
| number: ${fan_control_pin} | ||
| inverted: ${fan_control_inverted} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.