esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 34 forks source link

NeoPixelBus Light: Issue with multiple (GPIO) outputs on a single ESP32 #2877

Open Fitski opened 2 years ago

Fitski commented 2 years ago

The problem

In my kitchen, I want led strips (SK6812) on top of the kitchen cupboards, as well underneath them to shine on the counter. For this situation, I intend to use a single ESP32E configured with two NeoPixelBus platforms each having different GPIO output for each led strip. Unfortunately, I am not getting the desired behavior.

In HA, when I turn on "Kitchen Light Counter" (GPIO13).

The same thing happens when I turn on "Kitchen Light Up" which is, in this case, a good thing since that is the desired strip tied to that entity. After some troubleshooting such as: replacing ESP32 boards and using different GPIO pins, I tried the following scenario:

Instead of making two NeoPixelBus light components, I made just one. In this case, I only used "Kitchen Light Counter" (GPIO13) since it never lighted up in the previous scenario. To my surprise:

While there was technically one GPIO output configured, both led strips on different GPIO pins were turning on.

Finally, I tried to use the FastLed platform to see if the problem persists, but this worked like a charm (however, here I cannot use the white-led channel on the SK6812). Each led strip was controllable per HA entity.

At this point, ssieb (member on discord who helped me with most of the troubleshooting steps) stated that there might be an issue with the NeoPixelBus.

(these are one of my first filed issues on GitHub, feedback welcome)

Which version of ESPHome has the issue?

2021.12.1

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2021.12.5

What platform are you using?

ESP32-IDF

Board

espressif ESP32E development board.

Component causing the issue

NeoPixelBus Light

Example YAML snippet

esphome:
  name: esp32node-kitchen

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "eda3fd2f0c5db9bc5e49f268d1f1b662"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp32Node-Kitchen"
    password: "OyjiSYtd123Z"

captive_portal:

light:

- platform: neopixelbus
  variant: SK6812
  pin: GPIO13
  num_leds: 165
  type: GRBW
  id: kitchen_counter
  name: "Kitchen Light Counter"

- platform: neopixelbus
  variant: SK6812
  pin: GPIO16
  num_leds: 260
  type: GRBW
  id: kitchen_up
  name: "Kitchen Light Up"

Anything in the logs that might be useful for us?

No response

Additional information

No response

maik1607 commented 2 years ago

try to add a method with different channels, it helped me

Fitski commented 2 years ago

try to add a method with different channels, it helped me

Hi @maik1607, thanks for your reply. Can you elaborate on what you mean by "adding a method with different channels"? Perhaps you could share your configuration. Thank you in advance!

maik1607 commented 2 years ago

Sorry for the short reply. Here is part of my configuration:

light:
  - platform: neopixelbus
    type: RGB
    variant: WS2811
    method:
      type: esp32_rmt
      channel: 0
    pin: ${neopix_room1}
    num_leds: 20
    id: nxroom1
    internal: true
  - platform: neopixelbus
    type: RGB
    variant: WS2811
    method:
      type: esp32_rmt
      channel: 1
    pin: ${neopix_room2}
    num_leds: 20
    id: nxroom2
    internal: true
Fitski commented 2 years ago

Thank you @maik1607, This workaround works for me as well!

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

spali commented 1 year ago

can confirm this behavior still occurs in 2022.9.1. Configuring two light's with neopixelbus with different pins controls always the first defined light. And the workaround with the channels also still works.

raulgbcr commented 1 year ago

2022.10.2 seeing the same behaviour. Wondering if this is something wrong with neopixelbus and not ESPHome.

bigbangus commented 1 year ago

This fix works for me as well with HA and ESPHome 2022.12.

light:
  - platform: neopixelbus
    type: GRBW
    variant: SK6812
    pin: GPIO22
    method:
      type: esp32_rmt
      channel: 0
    num_leds: 84
    name: "Light 1"

  - platform: neopixelbus
    type: GRBW
    variant: SK6812
    pin: GPIO23
    method:
      type: esp32_rmt
      channel: 1
    num_leds: 54
    name: "Light 2"
Maaajaaa commented 1 year ago

I can confirm both the issue and workaround (pins GPIO5 and GPIO32 on ESP32)

fkollmann commented 7 months ago

For those using the NeoPixelBus directly, the following change is required to support multiple busses:

original code:

NeoPixelBus<NeoRgbFeature, Neo800KbpsMethod> pixels(CAR_LIGHTS_COUNT, CAR_LIGHTS_PIN);

updated code:

NeoPixelBus<NeoRgbFeature, NeoEsp32Rmt0800KbpsMethod> carPixels(CAR_LIGHTS_COUNT, CAR_LIGHTS_PIN);
NeoPixelBus<NeoRgbFeature, NeoEsp32Rmt1800KbpsMethod> riverPixels(RIVER_LIGHTS_COUNT, RIVER_LIGHTS_PIN)

For supporting multiple busses, make sure to have separate methods for each instance (the number after Rmt):

Please keep in mind the feature (Rgb, Rgbw, etc.) and method (800Kbps, 400Kbps, etc.) must match your neo pixel type.

ssieb commented 7 months ago

If it's an ESP32, you're better off using the RMT component instead.

Eric-IOT commented 5 months ago

Thank you @maik1607, This workaround works for me as well! using Lolin S3mini Home assistant and ESPHome 2023.12.9