Tips on using rpi_gpio_pwm platform with a pca9685 PMA board

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

  1. switched over with the manual install on Raspbian. I could not get it to work on HassIO.
  2. added the following to configuration.yaml
    Note: I am not 100% sure if the api: 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.

  1. Install pwmled
    pip install pwmled

  2. Ran sudo raspi-config --> Interface Options --> Enabled I2C
    note: I did this because I was getting the error: FileNotFoundError: [Errno 2] No such file or directory: '/dev/i2c-1'

  3. 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
  1. Then from some instructions here I also ran.
    sudo pigpiod

  2. (optional) run sudo i2cdetect -y 1 and made sure you see a “40”. Then run lsmod | grep i2c and sudo i2cdetect -l and make sure they look something like the below…
    It should look something like this…

  3. Wire-up the PCA9685. I followed this by Kevin Townsend in 2019.

  4. Reboot the entire pi (not just HA)
    sudo shutdown -r now

  5. 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

It seems that I have the same problem as you