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.
- 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 the
- platform: rpi_gpio_pwm
- name: Some Test Device
see here for all the options. For testing though, the above does work.
pip install pwmled
sudo raspi-config--> Interface Options --> Enabled
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.
sudo rm -rf PIGPIO
sudo make install
Then from some instructions here I also ran.
sudo i2cdetect -y 1and made sure you see a “40”. Then run
lsmod | grep i2cand
sudo i2cdetect -land 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.
- 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