WS2812B pixels in ESPHome

greetings all

I am trying to set up a TTGo camera board using ESPHome to control a few WS2812b pixels via IO21. The config below does talk to the pixels but there are issues. Camera works as do PIR and button.

light:
#  - platform:  neopixelbus
  - platform: fastled_clockless
#   chipset: neopixel
#    method: ESP32_RMT_0
#    chipset: NEOPIXEL
#    type: GRBW
#    variant: SK6812
#    chipset: ws2812b
#    chipset: SK6812
    pin: GPIO21
    num_leds: 1
    rgb_order: GRB
    name: "FastLED Light"

I also tried the neopixel bus variant trying the method: ESP32_RMT_0 and variant: SK6812 and any permutations that might make sense. Neopixel wanted to use SPI which was going down the wrong road except possibly when using IR modes - that appears to ‘mix’ the clock and data into a single stream. That didn’t go well either.

My main problem is that I cannot specify GRBW as I can using same physical setup in Arduino IDE. There I can control all 4 values for each led as expected. This is the relevant setup line:
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRBW + NEO_KHZ800)
In ESPHome, only GRB or some other 3 letter variant is allowed. Naturally, not being able to specify a white value is going to mess up control when each pixel needs 4 values instead of 3.

Is anyone making a GRBW config work with what are supposed to be WS2812B pixels in ESPHome? How please?

Thanks for your time.

Q

Are you sure you are using WS2812b pixels? WS2812b LEDs are not RGBW – only 3 color channels. The SK6812 have a white channel.

-JW

Thanks for your input Josh.

The pixels were billed as WS2812B. But is anything you buy from Amazon exactly what is advertised these days? I was under the (mistaken?) impression that the WS2812 was the the RGB or GRB variant and the WS2812B was a variant that included the “W” component. Having said that, as I (excessively?) briefly mentioned, the pixels work as expected in another code context - specifically Arduino IDE using Adafruit NeoPixel library on the very same hardware. I was hoping someone could tell me “the following config works with the ESP32 with the WS2812B for me…” so I could focus my efforts a little more effectively.

The problem for me is that the config in esp home that I expect should work:

  platformio_options:
    lib_deps: 
    - [email protected]
#    - [email protected]
    - AsyncTCP
#    - FastLED
#    - ESPAsyncWebServer-esphome

light:
  - platform:  neopixelbus
#  - platform: fastled_clockless
#   chipset: neopixel
    method: ESP32_RMT_0
#    chipset: NEOPIXEL
    type: GRBW
#    variant: 800KBPS
    variant: WS2812X
#    variant: SK6812
#    chipset: ws2812b
#    chipset: SK6812
    pin: GPIO22
    num_leds: 4
#    rgb_order: GRBW
    name: "FastLED Light"

yields warnings or errors on compile or uploads and fails to run properly. Not that the wrong colors result, etc. if that were the case I think I could find my errors. Error follows

[13:15:37]ets Jun  8 2016 00:22:57
[13:15:37]
[13:15:37]rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
[13:15:37]configsip: 0, SPIWP:0xee
[13:15:37]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
[13:15:37]mode:DIO, clock div:2
[13:15:37]load:0x3fff0018,len:4
[13:15:37]load:0x3fff001c,len:952
[13:15:37]load:0x40078000,len:6084
[13:15:37]load:0x40080000,len:7944
[13:15:37]entry 0x40080310
[13:15:37][I][logger:166]: Log initialized
[13:15:37][C][ota:366]: There have been 8 suspected unsuccessful boot attempts.
[13:15:37][I][app:029]: Running through setup()...
[13:15:37][D][binary_sensor:034]: 'PIR Sensor': Sending initial state OFF
[13:15:37][D][binary_sensor:034]: 'Button': Sending initial state ON
[13:15:38][D][esp-idf:000]: E (72) rmt: rmt_driver_install(725): RMT driver already installed for channel
[13:15:38]
[13:15:38]ESP_ERROR_CHECK failed: esp_err_t 0x103 (ESP_ERR_INVALID_STATE) at 0x4008de7c
[13:15:38]file: "/data/kitty_kam_front_shelter/.piolibdeps/kitty_kam_front_shelter/NeoPixelBus/src/internal/NeoEsp32RmtMethod.h" line 425
[13:15:38]func: void NeoEsp32RmtMethodBase<T_SPEED, T_CHANNEL>::Initialize() [with T_SPEED = NeoEsp32RmtSpeedWs2812x; T_CHANNEL = NeoEsp32RmtChannel0]
[13:15:38]expression: rmt_driver_install(T_CHANNEL::RmtChannelNumber, 0, ESP_INTR_FLAG_IRAM | ESP_INTR_FLAG_LEVEL1)
[13:15:38]
[13:15:38]Backtrace: 0x4008d980:0x3ffb1c60 0x4008de7f:0x3ffb1c80 0x400dea80:0x3ffb1ca0 0x400deb05:0x3ffb1cf0 0x400deb1a:0x3ffb1d30 0x4015a83d:0x3ffb1d50 0x400d6c01:0x3ffb1d70 0x4015ac4d:0x3ffb1d90 0x400dd34d:0x3ffb1db0 0x400df2f6:0x3ffb1e00 0x400e3e33:0x3ffb1fb0 0x4008a0c9:0x3ffb1fd0
[13:15:38]
[13:15:38]Rebooting...
[13:15:38]ets Jun  8 2016 00:22:57
[13:15:38]
[13:15:38]rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
[13:15:38]configsip: 0, SPIWP:0xee
[13:15:38]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
[13:15:38]mode:DIO, clock div:2
[13:15:38]load:0x3fff0018,len:4
[13:15:38]load:0x3fff001c,len:952
[13:15:38]load:0x40078000,len:6084
[13:15:38]load:0x40080000,len:7944
[13:15:38]entry 0x40080310
[13:15:38][I][logger:166]: Log initialized
[13:15:38][C][ota:366]: There have been 9 suspected unsuccessful boot attempts.
[13:15:38][I][app:029]: Running through setup()...
[13:15:38][D][binary_sensor:034]: 'PIR Sensor': Sending initial state OFF
[13:15:38][D][binary_sensor:034]: 'Button': Sending initial state ON
[13:15:38][D][esp-idf:000]: E (72) rmt: rmt_driver_install(725): RMT driver already installed for channel
[13:15:38]
[13:15:38]ESP_ERROR_CHECK failed: esp_err_t 0x103 (ESP_ERR_INVALID_STATE) at 0x4008de7c
[13:15:38]file: "/data/kitty_kam_front_shelter/.piolibdeps/kitty_kam_front_shelter/NeoPixelBus/src/internal/NeoEsp32RmtMethod.h" line 425
[13:15:38]func: void NeoEsp32RmtMethodBase<T_SPEED, T_CHANNEL>::Initialize() [with T_SPEED = NeoEsp32RmtSpeedWs2812x; T_CHANNEL = NeoEsp32RmtChannel0]
[13:15:38]expression: rmt_driver_install(T_CHANNEL::RmtChannelNumber, 0, ESP_INTR_FLAG_IRAM | ESP_INTR_FLAG_LEVEL1)
[13:15:38]
[13:15:38]Backtrace: 0x4008d980:0x3ffb1c60 0x4008de7f:0x3ffb1c80 0x400dea80:0x3ffb1ca0 0x400deb05:0x3ffb1cf0 0x400deb1a:0x3ffb1d30 0x4015a83d:0x3ffb1d50 0x400d6c01:0x3ffb1d70 0x4015ac4d:0x3ffb1d90 0x400dd34d:0x3ffb1db0 0x400df2f6:0x3ffb1e00 0x400e3e33:0x3ffb1fb0 0x4008a0c9:0x3ffb1fd0
[13:15:38]
[13:15:38]Rebooting...
[13:15:38]ets Jun  8 2016 00:22:57
[13:15:38]
[13:15:38]rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
[13:15:38]configsip: 0, SPIWP:0xee
[13:15:38]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
[13:15:38]mode:DIO, clock div:2
[13:15:38]load:0x3fff0018,len:4
[13:15:38]load:0x3fff001c,len:952
[13:15:38]load:0x40078000,len:6084
[13:15:38]load:0x40080000,len:7944
[13:15:38]entry 0x40080310
[13:15:38][I][logger:166]: Log initialized
[13:15:38][C][ota:366]: There have been 10 suspected unsuccessful boot attempts.
[13:15:38][E][ota:371]: Boot loop detected. Proceeding to safe mode.
[13:15:38][I][app:029]: Running through setup()...
[13:15:38][C][wifi:033]: Setting up WiFi...
[13:15:38][D][wifi:324]: Starting scan...
[13:15:40][D][wifi:339]: Found networks:
[13:15:40][I][wifi:385]: - 'XXXXXXXXXXXXXXXXXXXX ▂▄▆█
[13:15:40][D][wifi:386]:     Channel: 4
[13:15:40][D][wifi:387]:     RSSI: -43 dB
[13:15:40][I][wifi:194]: WiFi Connecting to 'Israel 2.4'...
[13:15:41][I][wifi:457]: WiFi Connected!
[13:15:41][C][wifi:303]:   SSID: 'XXXXXXX'
[13:15:41][C][wifi:304]:   IP Address: 192.168.1.142
[13:15:41][C][wifi:306]:   BSSID: XXXXXXXXXXXXXXXXX
[13:15:41][C][wifi:307]:   Hostname: 'kitty_kam_front_shelter'
[13:15:41][C][wifi:311]:   Signal strength: -42 dB ▂▄▆█
[13:15:41][C][wifi:315]:   Channel: 4
[13:15:41][C][wifi:316]:   Subnet: 255.255.255.0
[13:15:41][C][wifi:317]:   Gateway: 192.168.1.198
[13:15:41][C][wifi:318]:   DNS1: 0.0.0.0
[13:15:41][C][wifi:319]:   DNS2: 0.0.0.0
[13:15:41][C][ota:029]: Over-The-Air Updates:
[13:15:41][C][ota:030]:   Address: 192.168.1.142:3232
[13:15:41][C][ota:032]:   Using Password.
[13:15:41][W][ota:036]: Last Boot was an unhandled reset, will proceed to safe mode in 0 restarts
[13:15:41][I][app:059]: setup() finished successfully!
[13:15:41][I][ota:381]: Waiting for OTA attempt.
[13:15:41][I][app:105]: ESPHome version 1.15.3 compiled on Jan  1 2021, 13:04:48
[13:15:41][C][wifi:443]: WiFi:
[13:15:41][C][wifi:303]:   SSID: 'Israel 2.4'
[13:15:41][C][wifi:304]:   IP Address: 192.168.1.142
[13:15:41][C][wifi:306]:   BSSID: 50:6A:03:A6:AD:0F
[13:15:41][C][wifi:307]:   Hostname: 'kitty_kam_front_shelter'
[13:15:41][C][wifi:311]:   Signal strength: -38 dB ▂▄▆█
[13:15:41][C][wifi:315]:   Channel: 4
[13:15:41][C][wifi:316]:   Subnet: 255.255.255.0
[13:15:41][C][wifi:317]:   Gateway: 192.168.1.198
[13:15:41][C][wifi:318]:   DNS1: 0.0.0.0
[13:15:41][C][wifi:319]:   DNS2: 0.0.0.0
[13:15:41][C][logger:185]: Logger:
[13:15:41][C][logger:186]:   Level: DEBUG
[13:15:41][C][logger:187]:   Log Baud Rate: 115200
[13:15:41][C][logger:188]:   Hardware UART: UART0
[13:15:41][C][ota:029]: Over-The-Air Updates:
[13:15:41][C][ota:030]:   Address: 192.168.1.142:3232
[13:15:41][C][ota:032]:   Using Password.
[13:15:41][W][ota:036]: Last Boot was an unhandled reset, will proceed to safe mode in 0 restarts

The board ends up in a boot loop and I cannot access except by usb serial connection to reload.

As I understand it, to get this to work with neopixelbus, I must use method: ESP32_RMT_(x) which handles the merger of the clock and data using the Consumer IR hardware in the ESP32 into the single data line the WS2812B uses and nepixelbus allows a GRBW data format. This evidenced by the lack of an error for unsupported type. Other methods result in compile errors from not allocating the clock pin needed by other pixel chip types as one would expect.

Some other things to note.

  • I have started each attempt with a clean then compile.
  • Note that I have tried numerous variants (commented out) that did not result in errors flagged in error.
  • I am not now using - platform: fastled_clockless because it does not allow an rgb_order: GRBW.
  • I am now using ESPHome Current version: 1.15.3. I was unable to automagically upgrade from .2 but that is another issue. The .2 version showed green dot. but version numbers disagreed. Uninstall and reinstall ?fixed?.
  • While testing the pixels, I have commented out references to the oled display and the camera on the board in the ESPHome config file.
  • This same board works as-is in Arduino IDE with what is - to the best of my knowledge - an equivalent software setup. Essentially just a reference to the gpio pin for pixel data and how to use it.
  • I have discounted (see above) the mere presence of any existing components on the board- either active or passive as a cause of my problems.

Thanks again.

Q

UPDATE:

I don’t even approximately know what is going on… I am now able to get ESPH to compile and OTA upload a - platform: neopixelbus configuration that does not end up in boot loop. May have something to do with:

  platformio_options:
    lib_deps: 
    - [email protected]
    - AsyncTCP

I can’t tell. I speculate one of the incremental changes I made provoked a switch to fixed code during a clean build.

Pixels still aren’t working. Crashing is gone and data is coming out on the GPIO. Still not right and scope tells me it I need to do something to get the signal rise times improve. Will go back and test with Arduino IDE code and compare…

All in all, a little progress.

Q

Admittedly its late and I’m just browsing before bed, but i think your problem still revolves around what lights you’re actually using. WS2812B lights are RGB (no separate W channel). Further, the data line is a single wire (i.e no separate clock and data line…and hence is sensitive to timing). What labels are on your led strip pins? That may help to decipher what LEDs you’re working with.

-J

PS. I appreciate the level of detail in your posts.

I haven’t had any significant time to spend on this beyond:

Josh, you were correct that the pixels are SK6812 in all probability. I need to go back and test the Arduino IDE code with SK6812 specified. I suspect the driver is making some assumptions and helping me a little - whether either one of us (compiler or I) know it is happening is another matter…

There are no helpful markings. The chips are for sure clockless - power, ground, DI, DO.

The rise time of the data coming out of the ESP chip is awful. For this also, I need to go back to Arduino code to see if it is just as bad there - where the 4 pixels in the string work there just as they should. There may be a difference in how the IO pin is being set up.

PS- Thanks for the encouragement. It is always a challenge to give enough pertinent info. an not overdo it.

To wrap it up, It looks like I had problems with incorrect pixel type as well as issues with the ESPHome install - possibly a version update that fixed a problem with pixel support - and some error in my ESPH install that made uninstal > reinstall nessesary.

I am going to leave this unsolved for a bit.

Thanks again.

Q