A XIAO ESP32C3 is small enough to hide inside a lamp or a Diwali light controller, and a WS2812B strip gives it every colour. Data goes from D10 through 330 Ω; power comes from a separate 5 V adapter with a common ground.
The sketch runs an orange comet along a 30-LED strip at about 25 % brightness.
Wiring
| XIAO ESP32C3 | WS2812B addressable RGB LED strip (NeoPixel) | Wire | Notes |
|---|---|---|---|
| D10 | DIN | green | Via 330 Ω |
| 5 V 2 A adapter · +5V | 5V | red | 1000 µF capacitor across 5V/GND at the strip. |
| 5 V 2 A adapter · GND | GND | black | |
| GND | GND | black | Common ground with the XIAO. |
5 V (about 60 mA per LED at full white) part, 3.3 V board. The strip expects a data HIGH of about 3.5 V at 5 V supply. From ESP32 or Pico the 3.3 V signal often works with short wires, but to be safe drive DIN through a 74AHCT125 (or 74HCT125) powered from 5 V.
Board quirks
- D10 (GPIO10) has no boot role, so the strip stays dark during reset. Avoid D8/D9 (strapping) and D6 (TX, prints boot messages).
- The XIAO’s 3V3 pin can’t feed LEDs, and its 5V pin is just USB power — too little for a strip. Use a separate supply and join the grounds.
- On battery power (BAT pads), a strip is out of the question without its own supply: even 10 LEDs at full white draw more than the cell and regulator should give.
Code
// WS2812B strip on a Seeed XIAO ESP32C3.
// DIN → D10 (GPIO10) through 330 Ω. Strip 5V/GND → its own 5 V supply; supply GND → XIAO GND.
#include <Adafruit_NeoPixel.h>
constexpr uint16_t COUNT = 30;
Adafruit_NeoPixel strip(COUNT, D10, NEO_GRB + NEO_KHZ800);
void setup() {
Serial.begin(115200);
delay(1500);
strip.begin();
strip.setBrightness(60);
strip.show();
Serial.printf("WS2812B: %u LEDs on D10\n", COUNT);
}
void loop() {
// A "comet" running along the strip
static uint16_t head = 0;
for (uint16_t i = 0; i < COUNT; i++) {
uint16_t d = (head + COUNT - i) % COUNT;
uint8_t v = d < 8 ? 255 >> d : 0;
strip.setPixelColor(i, strip.Color(v, v / 3, 0));
}
strip.show();
head = (head + 1) % COUNT;
delay(40);
}// WS2812B strip on a Seeed XIAO ESP32C3.
// DIN → D10 (GPIO10) through 330 Ω. Strip 5V/GND → its own 5 V supply; supply GND → XIAO GND.
#include <Adafruit_NeoPixel.h>
constexpr uint16_t COUNT = 30;
Adafruit_NeoPixel strip(COUNT, D10, NEO_GRB + NEO_KHZ800);
void setup() {
Serial.begin(115200);
delay(1500);
strip.begin();
strip.setBrightness(60);
strip.show();
Serial.printf("WS2812B: %u LEDs on D10\n", COUNT);
}
void loop() {
// A "comet" running along the strip
static uint16_t head = 0;
for (uint16_t i = 0; i < COUNT; i++) {
uint16_t d = (head + COUNT - i) % COUNT;
uint8_t v = d < 8 ? 255 >> d : 0;
strip.setPixelColor(i, strip.Color(v, v / 3, 0));
}
strip.show();
head = (head + 1) % COUNT;
delay(40);
}Library: Adafruit NeoPixel (Adafruit) — compiled with Adafruit NeoPixel 1.15.5.
Expected serial output
WS2812B: 30 LEDs on D10WS2812B: 30 LEDs on D10
Common errors
First LED flickers or wrong colours
Marginal 3.3 V data. Keep the 330 Ω resistor close to the strip and the data wire short, or add a 74AHCT125 buffer.
XIAO resets when LEDs light
The strip shares the XIAO’s supply. Give it its own. Brownout fix.