2021-08-31 00:10:29 +02:00
H-bridge Fan
============
.. seo ::
:description: Instructions for setting up hbridge controlled fans (or motors).
2021-11-16 03:19:33 +01:00
:image: fan.svg
2021-08-31 00:10:29 +02:00
2022-04-03 09:30:25 +02:00
The `` hbridge `` fan platform allows you to use a compatible *h-bridge* (L298N, DRV8871, MX1508, BTS7960, L9110S, DRV8833, TB6612, etc.) to control a fan (or motor/solenoid).
2021-08-31 00:10:29 +02:00
.. figure :: images/L298N_module.jpg
:align: center
:target: `kuongshun`_
:width: 50.0%
L298N H-bridge module. Image by `kuongshun`_ .
.. _kuongshun: https://kuongshun.com/products/l298n-stepper-motor-driver-board-red
.. figure :: images/fan-ui.png
:align: center
:width: 80.0%
.. code-block :: yaml
# Example configuration entry
2021-12-22 23:14:39 +01:00
output:
- platform: ...
id: motor_forward_pin
pin: GPIO5
- platform: ...
id: motor_reverse_pin
pin: GPIO4
2022-04-03 09:30:25 +02:00
2021-08-31 00:10:29 +02:00
fan:
- platform: hbridge
2021-09-13 21:58:35 +02:00
id: my_fan
2021-08-31 00:10:29 +02:00
name: "Living Room Fan"
pin_a: motor_forward_pin
pin_b: motor_reverse_pin
# enable_pin: motor_enable
decay_mode: slow # slow decay mode (braking) or fast decay (coasting).
Configuration variables:
------------------------
- **pin_a** (**Required** , :ref: `config-id` ): The id of the
:ref: `float output <output>` connected to Pin A (alternatively IN1, etc.) of the h-bridge.
- **pin_b** (**Required** , :ref: `config-id` ): The id of the
:ref: `float output <output>` connected to Pin B (alternatively IN2, etc.) of the h-bridge.
2021-09-26 22:27:26 +02:00
- **enable_pin** (*Optional* , :ref: `config-id` ): The id of the
2021-08-31 00:10:29 +02:00
:ref: `float output <output>` connected to the Enable pin of the h-bridge (if h-bridge uses enable).
2021-09-26 22:27:26 +02:00
- **decay_mode** (*Optional* , string): The decay mode you want to use with
2021-08-31 00:10:29 +02:00
the h-bridge. Either `` slow `` (braking) or `` fast `` (coasting). Defaults to `` slow `` .
- **speed_count** (*Optional* , int): Set the number of supported discrete speed levels. The value is used
to calculate the percentages for each speed. E.g. `` 2 `` means that you have 50% and 100% while `` 100 ``
will allow 1% increments in the output. Defaults to `` 100 `` .
2022-01-10 00:07:19 +01:00
- **name** (**Required** , string): The name for this fan.
2021-08-31 00:10:29 +02:00
- **id** (*Optional* , :ref: `config-id` ): Manually specify the ID used for code generation.
- All other options from :ref: `Fan Component <config-fan>` .
.. _fan-hbridge_brake_action:
`` fan.hbridge.brake `` Action
----------------------------
Set all h-bridge pins high, shorting the fan/motor's windings and forcing the motor to actively stop.
.. code-block :: yaml
on_...:
then:
2021-09-13 21:58:35 +02:00
- fan.hbridge.brake: my_fan
2021-08-31 00:10:29 +02:00
See Also
--------
- :doc: `/components/output/index`
- :doc: `/components/fan/index`
- :doc: `/components/output/ledc`
- :doc: `/components/output/esp8266_pwm`
- :apiref: `fan/fan_state.h`
- `Adafruit's excellent H-bridge tutorial <https://learn.adafruit.com/improve-brushed-dc-motor-performance> `__
- :ghedit: `Edit`