WS2812 LED lighting on ESP32 with ESPHome

Addressable WS2812B strip on ESP32-C6 with ESPHome: 5 V supply, data resistor, YAML and Home Assistant light effects.

Goal: drive a WS2812B addressable LED strip from Home Assistant using an ESP32 board and ESPHome. This tutorial covers supply sizing, common ground, a 330 Ω data resistor, and a reliable YAML configuration.

Also in French: WS2812 lighting (FR) (overview hub).

Before you wire anything

  • Use a 5 V WS2812B strip (not 12 V or 24 V) and count your LEDs.
  • Size the PSU: about 60 mA per LED at full white → a 30-LED metre needs roughly 2 A; leave 20 % margin.
  • Share GND between the ESP32, the strip and the 5 V supply.
  • Put a 330 Ω resistor in series on the DIN line near the first pixel.

Prep guides: ESPHome temperature sensor · ESP32 project ideas · Which ESP32 board? · Smart home hub.

Minimal ESPHome YAML (excerpt)

light:

  • platform: neopixelbus type: GRB variant: WS2812 pin: GPIO18 num_leds: 30 name: “Cabinet strip” effects:
    • random:
    • strobe:
    • flicker:

Adopt the device in Home Assistant, then add the light entity to dashboards and automations (sunrise wake-up, movie scene, alert colour).

Troubleshooting

Symptom Likely cause Fix
First LEDs white, rest off Undersized 5 V supply Heavier PSU, inject power at both ends on long runs
Random colours Missing/common GND Tie ESP32 GND to strip GND and PSU −
No data Wrong GPIO or no resistor GPIO18 + 330 Ω on DIN; try level shifter on long cables
Flicker on effects Wi-Fi or power sag Separate PSU from USB hub; shorten data wire

← All smart-home guides

Further reading

Was this page helpful?

Have a question about this guide or need advice? Ask us here

Torn between two models or stuck on a build? Drop us a line and we will get back to you by email.