WS2812B strips need 5 V power and one data line. On the S2 Mini send data from GPIO5 through 330 Ω and run the strip from a separate 5 V adapter with a common ground.
The sketch runs a rainbow at about 25 % brightness and blinks the S2 Mini’s blue LED (GPIO15) slowly so you know the code is running.
Wiring
| LOLIN S2 Mini | WS2812B addressable RGB LED strip (NeoPixel) | Wire | Notes |
|---|---|---|---|
| 5 | 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 S2 Mini. |
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
- Don’t feed 5 V into VBUS while USB is plugged in: the S2 Mini has no reverse-current diode there. With the strip on its own supply and only GND shared, that problem never comes up.
- GPIO5 (D1 mini D0 position) has no boot role. The WS2812 D1 mini shield uses a different position — check its jumper and change
STRIP_PINto match. - The S2’s 3.3 V data usually drives a strip on a short wire; if the first LED flickers, add a 74AHCT125 buffer.
Code
// WS2812B strip on a LOLIN S2 Mini.
// DIN → GPIO5 through 330 Ω. Strip 5V/GND → its own 5 V supply; supply GND → S2 Mini GND.
#include <Adafruit_NeoPixel.h>
constexpr uint8_t STRIP_PIN = 5;
constexpr uint16_t COUNT = 30;
Adafruit_NeoPixel strip(COUNT, STRIP_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
Serial.begin(115200);
uint32_t t0 = millis();
while (!Serial && millis() - t0 < 3000) {}
strip.begin();
strip.setBrightness(60);
strip.show();
pinMode(LED_BUILTIN, OUTPUT); // blue LED on GPIO15
Serial.printf("WS2812B: %u LEDs on GPIO5\n", COUNT);
}
void loop() {
static uint16_t hue = 0;
for (uint16_t i = 0; i < COUNT; i++) {
strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(hue + i * 65536UL / COUNT)));
}
strip.show();
digitalWrite(LED_BUILTIN, (hue >> 14) & 1); // slow heartbeat on the blue LED
hue += 256;
delay(20);
}// WS2812B strip on a LOLIN S2 Mini.
// DIN → GPIO5 through 330 Ω. Strip 5V/GND → its own 5 V supply; supply GND → S2 Mini GND.
#include <Adafruit_NeoPixel.h>
constexpr uint8_t STRIP_PIN = 5;
constexpr uint16_t COUNT = 30;
Adafruit_NeoPixel strip(COUNT, STRIP_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
Serial.begin(115200);
uint32_t t0 = millis();
while (!Serial && millis() - t0 < 3000) {}
strip.begin();
strip.setBrightness(60);
strip.show();
pinMode(LED_BUILTIN, OUTPUT); // blue LED on GPIO15
Serial.printf("WS2812B: %u LEDs on GPIO5\n", COUNT);
}
void loop() {
static uint16_t hue = 0;
for (uint16_t i = 0; i < COUNT; i++) {
strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(hue + i * 65536UL / COUNT)));
}
strip.show();
digitalWrite(LED_BUILTIN, (hue >> 14) & 1); // slow heartbeat on the blue LED
hue += 256;
delay(20);
}Library: Adafruit NeoPixel (Adafruit) — compiled with Adafruit NeoPixel 1.15.5.
Expected serial output
WS2812B: 30 LEDs on GPIO5WS2812B: 30 LEDs on GPIO5
Common errors
Strip lights random colours at power-up, then works
Normal before the sketch starts. The 330 Ω resistor and the capacitor reduce it.
S2 Mini resets when the strip goes white
Strip is drawing from the board. Use its own supply. Brownout fix.