LEDs and sensors on esp32 - each works but not all together

Hello,

my plan is to make a night light for my boys. It should be controlled with a esp32 and have light and temperature sensors. My config below works for controlling the 21 LEDs but if I add the sensors the LEDs stop working. I get an “Component xxxxxx took a long time for an operation” in the logs.

Any hints what my problem is?

Thanks a lot!

esphome:
  name: esphome-web-9dab8c
  friendly_name: dino

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: secret

ota:


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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esphome-Web-9Dab8C"
    password: "d7rFSiLAIad4"

captive_portal:


i2c:
  - id: bus_a 
  #liochtsensor
    sda: 13
    scl: 16
    scan: true
  - id: bus_b
    temp + feuchtigkeit
    sda: 14
    scl: 15
    scan: true


sensor:

  - platform: bh1750
    name: "Dino-Helligkeit"
    i2c_id: bus_a
    address: 0x23
    update_interval: 60s    

  - platform: aht10
    variant: AHT20
    i2c_id: bus_b
    address: 0x38
    temperature:
      name: "Dino Temperatur"
    humidity:
      name: "Dino Feuchtigkeit"
    update_interval: 60s

light:
  - platform: partition
    name: "Dino LED Bauch"
    segments:
      - id: dinoled
        from: 0
        to: 7

  - platform: partition
    name: "Dino LED Rücken"
    segments:
      - id: dinoled
        from: 7
        to: 14

  - platform: partition
    name: "Dino LED Hals"
    segments:
      # Use first 10 LEDs from the light with ID light1
      - id: dinoled
        from: 15
        to: 19

  - platform: partition
    name: "Dino LED Kopf"
    segments:
      # Use first 10 LEDs from the light with ID light1
      - id: dinoled
        from: 20
        to: 21


  - platform: fastled_clockless
    chipset: WS2812
    pin: 32
    num_leds: 22
    rgb_order:  GRB
    name: "Dino LED"
    id: dinoled
    effects:
      - addressable_fireworks:
      - addressable_fireworks:
          name: Dino Feuerwerk
          update_interval: 320ms
          spark_probability: 100%
          use_random_color: true
          fade_out_rate: 120
      - addressable_color_wipe:
          name: Dino wird rot
          colors:
            - red: 100%
              green: 0%
              blue: 0%
              num_leds: 1
            - red: 80%
              green: 0%
              blue: 0%
              num_leds: 1
          add_led_interval: 10000ms
          reverse: false          
   # internal: true
 #   id: dino

Please post your log as well. The log can give us information what’s happening. I’m especially interested in the outcome of the I2C scan. I assume the message you mentioned is just a warning, that can be ignored.

However, why are you using two I2C busses? The I2C bus is designed to have 256 devices on one single bus as long as the devices all have unique addresses. So you can remove the second bus and also the line with id: bus_a and al the references to that id’s.

Furthermore if you still want two separate busses, there should be a # before temp + feuchtigkeit

1 Like

Thanks for your answer. Your comments on the IC2 bus are helpful, I will certainly change the wiring, for now I just use one sensor for testing. That was a case of copy pasting stuff from the internet instead of reading the documentation properly.

LED is showing up in home assistant and can be toggled there, but the light does not turn on. But if I reboot the esp32 after installing the changed configuration everything seems to work fine.

I think that solves my problem even though I do not understand the behaviour. As I prepared the post anyway here the config and the logs. If you have any comments let me know. You have been most helpful!

esphome:
  name: esphome-web-9dab8c
  friendly_name: dino

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: secret

ota:


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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esphome-Web-9Dab8C"
    password: "d7rFSiLAIad4"

captive_portal:


i2c:
# lichtsensor
    sda: 13
    scl: 16
    scan: true

sensor:
  - platform: bh1750
    name: "Dino-Helligkeit"
    address: 0x23
    update_interval: 60s    

light:
  - platform: partition
    name: "Dino LED Bauch"
    segments:
      # Use first 7 LEDs from the light with ID light1
      - id: dinoled
        from: 0
        to: 7

  - platform: partition
    name: "Dino LED Rücken"
    segments:
      - id: dinoled
        from: 7
        to: 14

  - platform: partition
    name: "Dino LED Hals"
    segments:
      - id: dinoled
        from: 15
        to: 19

  - platform: partition
    name: "Dino LED Kopf"
    segments:
      - id: dinoled
        from: 20
        to: 21


  - platform: fastled_clockless
    chipset: WS2812
    pin: 32
    num_leds: 22
    rgb_order:  GRB
    name: "Dino LED"
    id: dinoled
    effects:
      - addressable_fireworks:
      - addressable_fireworks:
          name: Dino Feuerwerk
          update_interval: 320ms
          spark_probability: 100%
          use_random_color: true
          fade_out_rate: 120
      - addressable_color_wipe:
          name: Dino wird rot
          colors:
            - red: 100%
              green: 0%
              blue: 0%
              num_leds: 1
            - red: 80%
              green: 0%
              blue: 0%
              num_leds: 1
          add_led_interval: 10000ms
          reverse: false          
   # internal: true
 #   id: dino

The log-output before reboot when the LED is not working, no warning message if the LED is working after reboot:

INFO ESPHome 2023.12.9
INFO Reading configuration /config/esphome/esphome-web-9dab8c.yaml...
INFO Starting log output from 192.168.3.171 using esphome API
INFO Successfully connected to esphome-web-9dab8c @ 192.168.3.171 in 7.224s
INFO Successful handshake with esphome-web-9dab8c @ 192.168.3.171 in 0.168s
[16:58:13][I][app:102]: ESPHome version 2023.12.9 compiled on Feb 17 2024, 16:54:10
[16:58:13][C][wifi:573]: WiFi:
[16:58:13][C][wifi:405]:   Local MAC: 78:21:84:9D:AB:8C
[16:58:13][C][wifi:410]:   SSID: 'beruehrtistfastgefangen'[redacted]
[16:58:13][C][wifi:411]:   IP Address: 192.168.3.171
[16:58:13][C][wifi:413]:   BSSID: 44:4E:6D:B4:B3:A3[redacted]
[16:58:13][C][wifi:414]:   Hostname: 'esphome-web-9dab8c'
[16:58:13][C][wifi:416]:   Signal strength: -72 dB ▂▄▆█
[16:58:13][C][wifi:420]:   Channel: 6
[16:58:13][C][wifi:421]:   Subnet: 255.255.255.0
[16:58:13][C][wifi:422]:   Gateway: 192.168.3.1
[16:58:13][C][wifi:423]:   DNS1: 192.168.3.2
[16:58:13][C][wifi:424]:   DNS2: 0.0.0.0
[16:58:13][C][logger:439]: Logger:
[16:58:13][C][logger:440]:   Level: DEBUG
[16:58:13][C][logger:441]:   Log Baud Rate: 115200
[16:58:13][C][logger:443]:   Hardware UART: UART0
[16:58:13][C][i2c.arduino:053]: I2C Bus:
[16:58:13][C][i2c.arduino:054]:   SDA Pin: GPIO13
[16:58:13][C][i2c.arduino:055]:   SCL Pin: GPIO16
[16:58:13][C][i2c.arduino:056]:   Frequency: 50000 Hz
[16:58:13][C][i2c.arduino:059]:   Recovery: bus successfully recovered
[16:58:13][I][i2c.arduino:069]: Results from i2c bus scan:
[16:58:13][I][i2c.arduino:075]: Found i2c device at address 0x23
[16:58:13][C][fastled:021]: FastLED light:
[16:58:13][C][fastled:022]:   Num LEDs: 22
[16:58:13][C][fastled:023]:   Max refresh rate: 400
[16:58:13][C][light:103]: Light 'Dino LED'
[16:58:13][C][light:105]:   Default Transition Length: 1.0s
[16:58:13][C][light:106]:   Gamma Correct: 2.80
[16:58:14][C][light:103]: Light 'Dino LED Bauch'
[16:58:14][C][light:105]:   Default Transition Length: 1.0s
[16:58:14][C][light:106]:   Gamma Correct: 2.80
[16:58:14][C][light:103]: Light 'Dino LED Rücken'
[16:58:14][C][light:105]:   Default Transition Length: 1.0s
[16:58:14][C][light:106]:   Gamma Correct: 2.80
[16:58:14][C][light:103]: Light 'Dino LED Hals'
[16:58:14][C][light:105]:   Default Transition Length: 1.0s
[16:58:14][C][light:106]:   Gamma Correct: 2.80
[16:58:14][C][light:103]: Light 'Dino LED Kopf'
[16:58:14][C][light:105]:   Default Transition Length: 1.0s
[16:58:14][C][light:106]:   Gamma Correct: 2.80
[16:58:14][C][bh1750.sensor:118]: BH1750 'Dino-Helligkeit'
[16:58:14][C][bh1750.sensor:118]:   Device Class: 'illuminance'
[16:58:14][C][bh1750.sensor:118]:   State Class: 'measurement'
[16:58:14][C][bh1750.sensor:118]:   Unit of Measurement: 'lx'
[16:58:14][C][bh1750.sensor:118]:   Accuracy Decimals: 1
[16:58:14][C][bh1750.sensor:119]:   Address: 0x23
[16:58:14][C][bh1750.sensor:124]:   Update Interval: 60.0s
[16:58:14][C][captive_portal:088]: Captive Portal:
[16:58:14][C][mdns:115]: mDNS:
[16:58:14][C][mdns:116]:   Hostname: esphome-web-9dab8c
[16:58:14][C][ota:097]: Over-The-Air Updates:
[16:58:14][C][ota:098]:   Address: esphome-web-9dab8c.local:3232
[16:58:14][C][api:139]: API Server:
[16:58:14][C][api:140]:   Address: esphome-web-9dab8c.local:6053
[16:58:14][C][api:142]:   Using noise encryption: YES
[16:58:18][D][light:036]: 'Dino LED' Setting:
[16:58:18][D][light:047]:   State: ON
[16:58:18][D][light:085]:   Transition length: 1.0s
[16:58:18][W][component:214]: Component light took a long time for an operation (0.06 s).
[16:58:18][W][component:215]: Components should block for at most 20-30ms.
[16:58:18][W][component:214]: Component light took a long time for an operation (0.06 s).
[16:58:18][W][component:215]: Components should block for at most 20-30ms.
[16:58:18][W][component:214]: Component light took a long time for an operation (0.06 s).
[16:58:18][W][component:215]: Components should block for at most 20-30ms.
[16:58:18][W][component:214]: Component light took a long time for an operation (0.06 s).
[16:58:18][W][component:215]: Components should block for at most 20-30ms.
[16:58:18][W][component:214]: Component light took a long time for an operation (0.06 s).
[16:58:18][W][component:215]: Components should block for at most 20-30ms.
[16:58:18][W][component:214]: Component light took a long time for an operation (0.06 s).
[16:58:18][W][component:215]: Components should block for at most 20-30ms.
[16:58:18][W][component:214]: Component light took a long time for an operation (0.06 s).
[16:58:18][W][component:215]: Components should block for at most 20-30ms.
[16:58:18][W][component:214]: Component light took a long time for an operation (0.06 s).
[16:58:18][W][component:215]: Components should block for at most 20-30ms.
[16:58:18][W][component:214]: Component light took a long time for an operation (0.06 s).
[16:58:18][W][component:215]: Components should block for at most 20-30ms.
[16:58:19][W][component:214]: Component light took a long time for an operation (0.06 s).
[16:58:19][W][component:215]: Components should block for at most 20-30ms.
[16:58:19][W][component:214]: Component light took a long time for an operation (0.06 s).
[16:58:19][W][component:215]: Components should block for at most 20-30ms.
[16:58:19][W][component:214]: Component light took a long time for an operation (0.06 s).
[16:58:19][W][component:215]: Components should block for at most 20-30ms.
[16:58:19][W][component:214]: Component light took a long time for an operation (0.06 s).
[16:58:19][W][component:215]: Components should block for at most 20-30ms.

Fastled seems to cause everyone problems for some reason. The Neopixel light seems to be more stable and have less issues IMO.

Thanks for the hint. I got it working as inteded with fastled but will try neopixel as well. Somehow I didn’t get / read the notificiation for you post - would have reacted sooner.