PCA9685 is killing wemos

Hello
I’m struggling with stairs led strips
I have wemos d1 mini + pca9685
On tasmota is working.
Onesphome latest version it seems that is totally killing CPU, OTA is impossible, logs dropping connection, device is resetting when script is initiated
Bellow you will find my code

substitutions: 
  device: schody
  room: Schody
  ip: 192.168.19.73
  transition_lenght: 400ms  
  stairs_awake_lenght: 20s 
  light_brightness: 51%
esphome:
  name: ${device}
  friendly_name: ${room}
  platform: ESP8266
  board: d1_mini

<<: !include common/common.yaml

status_led:
  pin: GPIO2

i2c:
  sda: D2
  scl: D1    
  scan: true 
  frequency: 10000 

pca9685:
  - id: pca9685_hub1
    frequency: 500
    address : 0x40

output:
  - platform: pca9685
    pca9685_id: 'pca9685_hub1'
    channel: 0
    id: pwm01
  - platform: pca9685
    pca9685_id: 'pca9685_hub1'
    channel: 1
    id: pwm02
  - platform: pca9685
    pca9685_id: 'pca9685_hub1'
    channel: 2
    id: pwm03
  - platform: pca9685
    pca9685_id: 'pca9685_hub1'
    channel: 3
    id: pwm04
  - platform: pca9685
    pca9685_id: 'pca9685_hub1'
    channel: 4
    id: pwm05
  - platform: pca9685
    pca9685_id: 'pca9685_hub1'
    channel: 5
    id: pwm06
  - platform: pca9685
    pca9685_id: 'pca9685_hub1'
    channel: 6
    id: pwm07
  - platform: pca9685
    pca9685_id: 'pca9685_hub1'
    channel: 7
    id: pwm08
  - platform: pca9685
    pca9685_id: 'pca9685_hub1'
    channel: 8
    id: pwm09
  - platform: pca9685
    pca9685_id: 'pca9685_hub1'
    channel: 9
    id: pwm10
  - platform: pca9685
    pca9685_id: 'pca9685_hub1'
    channel: 10
    id: pwm11
  - platform: pca9685
    pca9685_id: 'pca9685_hub1'
    channel: 11
    id: pwm12
  - platform: pca9685
    pca9685_id: 'pca9685_hub1'
    channel: 12
    id: pwm13
  - platform: pca9685
    pca9685_id: 'pca9685_hub1'
    channel: 13
    id: pwm14
  - platform: pca9685
    pca9685_id: 'pca9685_hub1'
    channel: 14
    id: pwm15
  - platform: pca9685
    pca9685_id: 'pca9685_hub1'
    channel: 15
    id: pwm16  

light:
  - platform: monochromatic
    name: 'Schodek 1'
    id: 'sc1'
    output: pwm01
    flash_transition_length: ${transition_lenght}
  - platform: monochromatic
    name: 'Schodek 2'
    id: 'sc2'
    output: pwm02
    flash_transition_length: ${transition_lenght}
  - platform: monochromatic
    name: 'Schodek 3'
    id: 'sc3'
    output: pwm03
    flash_transition_length: ${transition_lenght}
  - platform: monochromatic
    name: 'Schodek 4'
    id: 'sc4'
    output: pwm04
    flash_transition_length: ${transition_lenght}
  - platform: monochromatic
    name: 'Schodek 5'
    id: 'sc5'
    output: pwm05
    flash_transition_length: ${transition_lenght}
  - platform: monochromatic
    name: 'Schodek 6'
    id: 'sc6'
    output: pwm06
    flash_transition_length: ${transition_lenght}
  - platform: monochromatic
    name: 'Schodek 7'
    id: 'sc7'
    output: pwm07
    flash_transition_length: ${transition_lenght}
  - platform: monochromatic
    name: 'Schodek 8'
    id: 'sc8'
    output: pwm08
    flash_transition_length: ${transition_lenght}
  - platform: monochromatic
    name: 'Schodek 9'
    id: 'sc9'
    output: pwm09
    flash_transition_length: ${transition_lenght}
  - platform: monochromatic
    name: 'Schodek 10'
    id: 'sc10'
    output: pwm10
    flash_transition_length: ${transition_lenght}
  - platform: monochromatic
    name: 'Schodek 11'
    id: 'sc11'
    output: pwm11
    flash_transition_length: ${transition_lenght}
  - platform: monochromatic
    name: 'Schodek 12'
    id: 'sc12'
    output: pwm12
    flash_transition_length: ${transition_lenght}
  - platform: monochromatic
    name: 'Schodek 13'
    id: 'sc13'
    output: pwm13
    flash_transition_length: ${transition_lenght}
  - platform: monochromatic
    name: 'Schodek 14'
    id: 'sc14'
    output: pwm14
  - platform: monochromatic
    name: 'Schodek 15'
    id: 'sc15'
    output: pwm15
    flash_transition_length: ${transition_lenght}
  - platform: monochromatic
    name: 'Schodek 16'
    id: 'sc16'
    output: pwm16
    flash_transition_length: ${transition_lenght} 

switch:
  - platform: restart
    name: "${room} Restart"

binary_sensor:
    - platform: gpio
      pin:
        number: D6
        mode:
          input: true
          pullup: true
        inverted: true
      name: "${room} czujnik dolny"
    - platform: gpio
      pin:
        number: D7
        mode:
          input: true
          pullup: true
        inverted: true
      name: "${room} czujnik górny" 
button:    
  - platform: template
    name: "Schody dół góra"
    id: lightdownupon
    on_press:
     then:
      - script.execute: schodydowupnon
      - delay: ${stairs_awake_lenght}
      - script.execute: schodydowupnoff
   
        

  - platform: template
    name: "Schody góra dół"
    id: lightupdownon
    on_press:
     then:
     - script.execute: schodyupdownon
     - delay: ${transition_lenght}
     - script.execute: schodyupdownoff
     

script:
  - id: schodyupdownon
    then:  
     - light.turn_on:
        id: sc16
        brightness: ${light_brightness}
     - delay: ${transition_lenght}
     - light.turn_on:
        brightness: ${light_brightness}
        id: sc15
     - delay: ${transition_lenght}
     - light.turn_on:
        brightness: ${light_brightness}
        id: sc14
     - delay: ${transition_lenght}
     - light.turn_on:
        id: sc13
        brightness: ${light_brightness}
     - delay: ${transition_lenght}
     - light.turn_on:
        id: sc12
        brightness: ${light_brightness}
     - delay: ${transition_lenght}
     - light.turn_on:
        id: sc11
        brightness: ${light_brightness}
     - delay: ${transition_lenght}
     - light.turn_on:
        id: sc10
        brightness: ${light_brightness}
     - delay: ${transition_lenght}
     - light.turn_on:
        id: sc9
        brightness: ${light_brightness}
     - delay: ${transition_lenght}
     - light.turn_on:
        id: sc8
        brightness: ${light_brightness}
     - delay: ${transition_lenght}
     - light.turn_on:
        id: sc7
        brightness: ${light_brightness}
     - delay: ${transition_lenght}
     - light.turn_on:
        id: sc6
        brightness: ${light_brightness}
     - delay: ${transition_lenght}
     - light.turn_on:
        id: sc5
        brightness: ${light_brightness}
     - delay: ${transition_lenght}
     - light.turn_on:
        id: sc4
        brightness: ${light_brightness}
     - delay: ${transition_lenght}
     - light.turn_on:
        id: sc3
        brightness: ${light_brightness}
     - delay: ${transition_lenght}
     - light.turn_on:
        id: sc2
        brightness: ${light_brightness}    

  - id: schodyupdownoff
    then:  
     - light.turn_on:
        id: sc1
        brightness: ${light_brightness}
     - delay: ${stairs_awake_lenght}
     - light.turn_off:
        id: sc16
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc15
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc14
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc13
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc12
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc11
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc10
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc9
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc8
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc7
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc6
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc5
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc4
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc3
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc2
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc1   

  - id: schodydowupnon
    then:   
     - light.turn_on:
        brightness: ${light_brightness}
        id: sc1
     - delay: ${transition_lenght}
     - light.turn_on:
        brightness: ${light_brightness}
        id: sc2
     - delay: ${transition_lenght}
     - light.turn_on:
        id: sc3
        brightness: ${light_brightness}
     - delay: ${transition_lenght}
     - light.turn_on:
        id: sc4
        brightness: ${light_brightness}
     - delay: ${transition_lenght}
     - light.turn_on:
        id: sc5
        brightness: ${light_brightness}
     - delay: ${transition_lenght}
     - light.turn_on:
        id: sc6
        brightness: ${light_brightness}
     - delay: ${transition_lenght}
     - light.turn_on:
        id: sc7
        brightness: ${light_brightness}
     - delay: ${transition_lenght}
     - light.turn_on:
        id: sc8
        brightness: ${light_brightness}
     - delay: ${transition_lenght}
     - light.turn_on:
        id: sc9
        brightness: ${light_brightness}
     - delay: ${transition_lenght}
     - light.turn_on:
        id: sc10
        brightness: ${light_brightness}
     - delay: ${transition_lenght}
     - light.turn_on:
        id: sc11
        brightness: ${light_brightness}
     - delay: ${transition_lenght}
     - light.turn_on:
        id: sc12
        brightness: ${light_brightness}
     - delay: ${transition_lenght}
     - light.turn_on:
        id: sc13
        brightness: ${light_brightness}
     - delay: ${transition_lenght}
     - light.turn_on:
        id: sc14
        brightness: ${light_brightness}
     - delay: ${transition_lenght}
     - light.turn_on:
        id: sc15
        brightness: ${light_brightness}
     - delay: ${transition_lenght}
     - light.turn_on:
        id: sc16
        brightness: ${light_brightness}   
    
  - id: schodydowupnoff
    then:       
     - light.turn_off:
        id: sc1
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc2
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc3
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc4
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc5
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc6
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc7
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc8
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc9
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc10
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc11
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc12
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc13
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc14
     - delay: ${transition_lenght}
     - light.turn_off:
        id: sc15
     - delay: ${transition_lenght}   
     - light.turn_off:
        id: sc16

Have you checked the current draw of the LEDs?

Max current per pin is 25mA.

Is the d1mini an authentic one or a clone? The clones can be flakey.

Per the datasheet, page 19, IMAX is 12 mA

I was referring to the output pins of the pca9685, which can be powered independently of the esp (or you can power it via the esp).

From section 7.7 of the data sheet.

“The PCA9685 LED output drivers are 5.5V only tolerant and can sink up to 25mA at 5V. If the device needs to drive LEDs to a higher voltage and/or higher current, use of an external driver is required.”

I had to throw in some mosfets for my project.

That occurred to me after I posted. Also, if it works on Tasmota, then it should work with ESPHome.

1 Like

I was thinking perhaps they may have done lighter duty testing on Tasmota or changed something else after migration…

Hi,
Thanks for quick answer,
Seems that issue is related with script and button part.
When I delete it, device behavior is back to normal…
Only lights remains…
Do you have an idea how to make to sequentially start led strip on each stair?

Not sure exactly what you mean but script.wait might help?