Trouble configuring an SK6812 LED strip on M5Stack Atom Lite w/ PbHUB

I am building a lamp project (lamp plus other stuff) using the following components:

I want to be able to use the built-in SK6812 (single) LED on the Atom Lite as a sort of “status light”, while the LED Strip will be used as the lamp element. I also have the built-in button working on GPIO39.
Here is the YAML that works with just the “status light”:

esphome:
  name: [device-name]
  friendly_name: [Friendly Name]
  area: [area]
  on_boot:
    then:
      - light.turn_on:
          id: built_in_led
          brightness: 25%
          red: 100%
          green: 0%
          blue: 0%

esp32:
  board: esp32dev
  framework:
    type: Arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: {encryption key}

ota:
  password: {ota password}

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: {something}
    password: {something}

captive_portal:

i2c:
  sda: 21
  scl: 22
  scan: True

light:
  - platform: neopixelbus
    id: built_in_led
    name: Built-in LED
    pin: GPIO27
    num_leds: 1
    variant: SK6812
    entity_category: diagnostic

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO39
      inverted: true
    id: primary_button
    name: Primary Button

As mentioned, this works exactly as you might expect.

Once I connect the PbHUB to the GROVE connector on the Atom Lite, and then plug the LED Strip into the hub (channel 3)… shenanigans ensue…

  1. The “status light” that should turn on, red, on boot, does not turn on at boot
  2. The “Built-in LED” entity in Home Assistant shows “on” and “red”, even though the light is not actually on.
  3. The “Pb.HUB LED Strip” entity in Home Assistant controls the built-in LED, but not the LED strip.
    • Meaning, even though the “Built-in LED” entity does not control the onboard LED, changing the state, color, or brightness of the “Pb.HUB LED Strip” entity in Home Assistant does control the built-in LED.

I’ve scoured the documentation for both the PbHUB and the LED strip, but cannot, for the life of me, figure out what I’m doing wrong. I found one post on the m5stack forums that involved the PbHUB, but that person was connecting sensors and using the “address” mapping for the sensors. NeoPixel does not accept “address” as an option.

Here is the YAML code with my attempts to configure the LED strip.

esphome:
  name: [device-name]
  friendly_name: [Friendly Name]
  area: [area]
  on_boot:
    then:
      - light.turn_on:
          id: built_in_led
          brightness: 25%
          red: 100%
          green: 0%
          blue: 0%

esp32:
  board: esp32dev
  framework:
    type: Arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: {encryption key}

ota:
  password: {ota password}

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: {something}
    password: {something}

captive_portal:

i2c:
  sda: 21
  scl: 22
  scan: True

light:
  - platform: neopixelbus
    id: built_in_led
    name: Built-in LED
    pin: GPIO27
    num_leds: 1
    variant: SK6812
    entity_category: diagnostic
  - platform: neopixelbus
    id: pb_hub_led_strip
    name: Pb.HUB LED Strip
# all of these PIN options are commented out solely for the purposes of sharing the code. I've tried all of these.
#    pin: 19     # Channel 3 on the Pb.HUB ?
#    pin: GPIO21     # from the m5stack documentation for the LED strip
#    pin: GPIO27     # Same GPIO as the built-in LED
    variant: SK6812
    num_leds: 29
    effects:
      - addressable_rainbow:
      - addressable_color_wipe:
      - addressable_scan:
      - addressable_twinkle:

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO39
      inverted: true
    id: primary_button
    name: Primary Button

I’ve made some incremental progress. With the LED Strip connected directly to the GROVE port on the Atom Lite, this modified light block works as intended. I’m going to try this with the LED Strip connected to the PbHUB next.

light:
  - platform: esp32_rmt_led_strip
    id: status_led
    name: Status LED
    disabled_by_default: true
    entity_category: config
    pin: GPIO27
    default_transition_length: 0s
    chipset: SK6812
    num_leds: 1
    rgb_order: grb
    rmt_channel: 0
    effects:
      - pulse:
          transition_length: 250ms
          update_interval: 250ms
  - platform: neopixelbus
    id: led_strip
    name: LED Strip
    pin: GPIO21
    variant: SK6812
    num_leds: 29
    effects:
      - addressable_rainbow:
      - addressable_color_wipe:
      - addressable_scan:
      - addressable_twinkle:
1 Like

So, while trying to get the LED strip to work on the PbHUB, I somehow broke everything, which I guess is an expected part of this process. I ended up finding someone, though, that’s already written a custom component for the PbHUB and ESPHome: Chill-Division (GitHub).

Using this custom component, I was able to get the M5Stack Dual Button that I also want to use working while connected to the PbHUB. I’m working on incorporating the LED strip at this point, but running into an issue where the light config for the LED strip doesn’t like the pin configuration I’ve written. I get This variable only supports pin numbers, not full pin schemas (with inverted and mode). on the pin: > number: 30 line (line 117).

esphome:
  name: {something}
  friendly_name: {something}
  area: {something}
  libraries:
    - Wire
  on_boot:
    then:
      - light.turn_on:
          id: status_led
          brightness: 30%
          red: 100%
          green: 0%
          blue: 0%
      - light.turn_on:
          id: led_strip
          brightness: 30%
          red: 50%
          green: 0%
          blue: 50%

esp32:
  board: m5stack-atom
  framework:
    type: arduino

# Enable logging
logger:
  level: VERY_VERBOSE

# Enable Home Assistant API
api:
  encryption:
    key: {something}

ota:
  password: {something}

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: {something}
    password: {something}

captive_portal:

# Disabling I2C for now since the PbHUB is using the same pins
#i2c:
#  sda: 26     # grove connector, per https://docs.m5stack.com/en/core/atom_lite
#  scl: 32     # grove connector, per https://docs.m5stack.com/en/core/atom_lite
#  id: grove
#  frequency: 400 kHz
#  scan: true

spi:
  clk_pin: 23     # per https://docs.m5stack.com/en/core/atom_lite
  mosi_pin: 19     # per https://docs.m5stack.com/en/core/atom_lite
  miso_pin: 33     # per https://docs.m5stack.com/en/core/atom_lite

# Custom component for the M5Stack Pb.HUB
external_components:
  - source:
      type: git
      url: https://github.com/chill-Division/M5Stack-ESPHome/
      ref: main
    components: m5stack_pbhub
# Pin numberring in the PbHUB (The first digit is the channel number and the second digit is the pin number)
  # CHANNEL 0 : 00 and 01
  # CHANNEL 1 : 10 and 11
  # CHANNEL 2 : 20 and 21
  # CHANNEL 3 : 30 and 31
  # CHANNEL 4 : 40 and 41
  # CHANNEL 5 : 50 and 51

# M5Stack PbHUB device configuration
m5stack_pbhub:
  - id: 'M5Stack_HUB'
    address: 0x61 # Base I2C Address
    sda: 26 # I2C SDA Pin (Yellow grove cable)
    scl: 32 # I2C SCL Pin (White grove cable)

light:
  # Built-in RGB LED (SK6812) on GPIO27
  - platform: esp32_rmt_led_strip
    id: status_led
    name: Status LED
    entity_category: diagnostic
    pin: GPIO27
    default_transition_length: 0s
    chipset: SK6812
    num_leds: 1
    rgb_order: grb
    rmt_channel: 0
    effects:
      - pulse:
          transition_length: 250ms
          update_interval: 250ms

  # M5Stack RGB LED Strip (SK6812) on Pb.HUB Ch 3
  - platform: neopixelbus
    id: led_strip
    name: LED Strip
#    pin: GPIO26     # from the grove port
#    pin: GPIO32     # grove i2c
#    pin: GPIO25     # i2c data pin 25
#    pin: GPIO21     # works with scl 21 / sda 25 WITHOUT the built-in led configured; does not work when built-in led is configured
#    pin: GPIO23     # google bard conversation
    pin:
      m5stack_pbhub: M5Stack_HUB
      # Use channel 3, pin number 0
      number: 30  # error: This variable only supports pin numbers, not full pin schemas (with inverted and mode)
      mode:
        output: true
    variant: SK6812
    num_leds: 29
    effects:
      - addressable_rainbow:
      - addressable_color_wipe:
      - addressable_scan:
      - addressable_twinkle:

binary_sensor:
  # Built-in button on GPIO39
  - platform: gpio
    pin:
      number: GPIO39
      inverted: true
    id: primary_button
    name: Primary Button

  # M5Stack Dual Button on Pb.HUB Ch 5, red button
  - platform: gpio
    pin:
      m5stack_pbhub: M5Stack_HUB
      # Use channel 5, pin number 0
      number: 50
      mode:
        output: true
      inverted: true
    id: red_button
    name: Red Button

  # M5Stack Dual Button on Pb.HUB Ch 5, blue button
  - platform: gpio
    pin:
      m5stack_pbhub: M5Stack_HUB
      # Use channel 5, pin number 1
      number: 51
      mode:
        output: true
      inverted: true
    id: blue_button
    name: Blue Button

Were you ever able to get the light config to accept the pbhub pin? Running into the same issue with ADC. It wants a numeric pin only