Hi there,
I have a esp32 connected to a pca9685 and trying to use the pwm to control a fan that requires 22kHz pwm signal to be happy.
In Components ➔ Output Component ➔ PCA9685 it states in the example that an external clock mode is available and we are shown an example that does not work since I don’t get any pwm on the oscilloscope.
Wire connections between esp32 and pca: just clasic i2c, power (3v3,+,-) and scl & sda.
Pca9685 has external (v+) 5v connected to be transmitted to the outputs.
With internal pca9685 clock source I get a 0.02 difference which is perfect so I can confirm it’s not a hardware issue, with external_clock_input: true I get no signal on the oscilloscope.
Here is the code I use:
i2c:
sda: 21
scl: 22
scan: true
id: i2c_bus_a
frequency: 100kHz
# Example configuration entry with external clock enable and clock source from ESP32
pca9685:
- id: pca9685_hub1
external_clock_input: true
# - address: 0x40 ## Default 0x40 - this requires setting frq manualy? - incompatible with external_clock_input
# frequency: 1525 ## !!! Sets FRQ for all pins - does not work with external_clock_input true Frequency cannot be set when using an external clock input. 24Hz to 1525.88Hz. Default 1000Hz
# Individual outputs
output:
# generate PWM from ESP32 ledc
## frequency range of LEDC is from 10Hz to 40MHz - however, higher frequencies require a smaller bit depth which means the output is not that accurate for frequencies above ~300kHz.
- platform: ledc
pin: GPIO5 ## The pin to use LEDC on. Can only be GPIO0-GPIO33.
id: extclk
min_power: 0
max_power: 1 ## between 0.00 and 1
#inverted: true
frequency: 22khz ## Preffered Delta PFC1212DE pwm frequency
- platform: pca9685
#pca9685_id: pca9685_hub1 ## Use this if you have multiple PCA9685s you want to use at the same time.
id: pwm_ch_0
channel: 0 ## 0 to 15
fan:
- platform: speed
output: pwm_ch_0 ## id of the float output to use for this fan
name: "Delta PFC1212DE"
My questions are:
-
Is the code correct?
-
How is the clock transmited from esp32 to pca9685? ( this is why I added 100kHz to i2c bus frequency but changed nothing on the output of pca ).
-
What is happening with the output of GPIO5 on the ESP since I can’t see any pwm on it on the oscilloscope.
Any help would be much appreciated.