PCA9685
Component/Hub
Section titled “Component/Hub”The PCA9685 component represents a PCA9685 12-bit PWM driver (datasheet, adafruit) in ESPHome. It uses I²C Bus for communication.
To use the channels of this components, you first need to setup the
global pca9685 hub and give it an id, and then define the
individual output channels.
# Example configuration entrypca9685: - id: pca9685_hub1 frequency: 500
# Individual outputsoutput: - platform: pca9685 pca9685_id: 'pca9685_hub1' channel: 0# Example configuration entry with external clock enable and clock source from ESP32pca9685: - id: pca9685_hub1 external_clock_input: true
# Individual outputsoutput: # generate PWM from ESP32 ledc - platform: ledc pin: GPIOXX id: extclk min_power: 1 frequency: 40MHz
- platform: pca9685 pca9685_id: 'pca9685_hub1' channel: 0# Example configuration entry with disabled phase_balancerpca9685: - id: pca9685_hub1 phase_balancer: none
# Individual outputsoutput: - platform: pca9685 pca9685_id: 'pca9685_hub1' channel: 0 - platform: pca9685 pca9685_id: 'pca9685_hub1' channel: 1Configuration variables
Section titled “Configuration variables”-
frequency (Optional, frequency): The frequency to let the component drive all PWM outputs at. Must be in range from
23.84Hzto1525.88Hz. Defaults to1kHz. -
external_clock_input (Optional, bool): Enable external clock input. PRE_SCALE register will by set to 3. Default to
false. -
address (Optional, int): The I²C address of the driver. Defaults to
0x40. -
id (Optional, ID): The id to use for this pca9685 component. Use this if you have multiple PCA9685s connected at the same time
-
phase_balancer (Optional, string): The phase balancer algorithm to use. See Phase Balancer below.
Phase Balancer
Section titled “Phase Balancer”The PCA9685 allows setting different phase angles on each output. The following algorithms can be used to set the phase angle of each output:
linear(default): The phase angle is set by distributing all defined outputs equally among 360°. So with 3 outputs the first would have 0°, the second 120° and the last 240°. This algorithm can cause flickering when animating the light, because the PCA9685 chip will need an additional frame where no PWM is generated if the start angle is higher than the stop angle.none: The phase angle is always 0°. This is the safer option if you control LED lights.
PCA9685 Output
Section titled “PCA9685 Output”The PCA9685 output component exposes a PCA9685 PWM channel of a global PCA9685 hub as a float output.
# Example configuration entrypca9685: - frequency: 500
# Individual outputsoutput: - platform: pca9685 id: 'pca9685_output1' channel: 0Configuration variables
Section titled “Configuration variables”-
id (Required, ID): The id to use for this output component.
-
channel (Required, int): Choose the channel of the PCA9685 of this output component. Must be in range from 0 to 15.
-
pca9685_id (Optional, ID): Manually specify the ID of the PCA9685 hub. Use this if you have multiple PCA9685s you want to use at the same time.
-
All other options from Output.
Examples
Section titled “Examples”This output can be used for different PWM functions. E.g. output for light, fan etc.
pca9685: frequency: 500
output: - platform: pca9685 channel: 0 id: pwm01
light: - platform: monochromatic name: 'main light' output: pwm01