How to specify nanosecond in configuration file?

My configuration:

light:
  - platform: esp32_rmt_led_strip
    rgb_order: GRB
    pin: GPIO16
    num_leds: 2
    rmt_channel: 0
    name: "My Light"
    # chipset: ws2812
    bit0_high: 0.35us
    bit0_low: 0.9us
    bit1_high: 0.9us
    bit1_low: 0.35us

When I compile, it complains:

But I can’t use ns either.
image

Esphome doesn’t support nanosecond resolution. Microseconds is the finest resolution you’re gonna get.

Then how can I use esp32_rmt_led_strip?

Depends on what chipset your ledstrip uses. Which is?

By following these instructions? ESP32 RMT LED Strip — ESPHome

It’s WS2812B, which has a different timing than WS2812.

I got the error by following these instructions.

What error?

Also if there is that much of a difference between ws2812 and ws2812b, then the b is not in the supported devices list.

Please read my post, I wrote the error there, and this is the timing diagram of both:

I don’t know what you mean. ws2812b doesn’t exist in the support list of esp32_rmt_led_strip, but it does exist in fastled_wireless, although, fastled_wireless doesn’t work on my board.

The question is not about what chipset to use, it it about using the optional custom timing values.

I think this is a bug, there are no examples I can find that use the custom timing setting. The example in the original pull request (Create esp32 rmt addressable light driver by jesserockz · Pull Request #4708 · esphome/esphome · GitHub) write it as

# Example config.yaml
light:
  - platform: esp32_rmt_led_strip
    pin: GPIO27
    num_leds: 1
    chipset: SK6812
    # bit0_high: 300us
    # bit0_low: 900us
    # bit1_high: 600us
    # bit1_low: 600us
    rgb_order: GRB
    rmt_channel: 0
    max_refresh_rate: 10ms
    name: LED Strip
    id: led
    effects:
      - addressable_rainbow:
      - pulse:

So, they are off by a factor of 1000 (and only as a comment). All test yalm files are the same, either off by 1000 or comment.

The source code for setting these values are:

void ESP32RMTLEDStripLightOutput::set_led_params(uint32_t bit0_high, uint32_t bit0_low, uint32_t bit1_high,
                                                 uint32_t bit1_low) {
  float ratio = (float) APB_CLK_FREQ / RMT_CLK_DIV / 1e09f;

  // 0-bit
  this->bit0_.duration0 = (uint32_t) (ratio * bit0_high);
  this->bit0_.level0 = 1;
  this->bit0_.duration1 = (uint32_t) (ratio * bit0_low);
  this->bit0_.level1 = 0;
  // 1-bit
  this->bit1_.duration0 = (uint32_t) (ratio * bit1_high);
  this->bit1_.level0 = 1;
  this->bit1_.duration1 = (uint32_t) (ratio * bit1_low);
  this->bit1_.level1 = 0;
}

But I can’t find where bit0_ and bit1_ are used, but I can’t say that I fully understand the source code.

Hi @UchihaYuki, were you ever able to find a resolution for this? I’ve just run into it myself with some WS2814 LEDs. Thanks!