I ran across a PWM LED Light article and it inspired me to buy a PCA9685 but I REALLY struggled to get it to work. In the end, I did though. Here are my notes in case anyone else wants to try and get a PCA9685 controller working. I mostly made these notes for myself so I could recreate this if needed but wanted to share it out with everyone else. Just as an FYI, I am not sure if all these steps are required they are just some things I did that seemed to get it to work.
Instructions
- switched over with the manual install on Raspbian. I could not get it to work on HassIO.
- added the following to configuration.yaml
Note: I am not 100% sure if theapi:
is required.
api:
light:
- platform: rpi_gpio_pwm
leds:
- name: Some Test Device
driver: pca9685
pins: [1]
type: simple
see here for all the options. For testing though, the above does work.
-
Install pwmled
pip install pwmled
-
Ran
sudo raspi-config
--> Interface Options --> EnabledI2C
note: I did this because I was getting the error:FileNotFoundError: [Errno 2] No such file or directory: '/dev/i2c-1'
-
followed the instructions from here
note: The first two lines are cleanup and may not be needed.
rm pigpio.zip
sudo rm -rf PIGPIO
wget abyz.me.uk/rpi/pigpio/pigpio.zip
unzip pigpio.zip
cd PIGPIO
make
sudo make install
-
Then from some instructions here I also ran.
sudo pigpiod
-
(optional) run
sudo i2cdetect -y 1
and made sure you see a “40”. Then runlsmod | grep i2c
andsudo i2cdetect -l
and make sure they look something like the below…
It should look something like this…
-
Wire-up the PCA9685. I followed this by Kevin Townsend in 2019.
-
Reboot the entire pi (not just HA)
sudo shutdown -r now
-
Now I see “Some Test Device” on my Home screen. When I switch it on and off I see the LED connected between GND and PWM turn on and off.
Notes
- I’m don’t know this stuff very well. I have only been playing with my Rasp Pi for about a month.
- Hardware: Raspberry Pi 4 Model B 4GB.
- Device: PCA9685 12-bit PWM (same as drawing above)
- OS: Raspbian Buster with desktop and software; Release date:2019-09-26; Kernel ver:4.19
- Home-Assistant: Home Assistant 0.103.0