WS2812B addressable LED strip with ESP32
Supply 5 V
Bus GPIO
Pins and ESP32 wiring
| Pin | Role | ESP32 pin | Notes |
|---|---|---|---|
| 5V | Power | VIN | Use VIN for a few LEDs; a separate 5 V supply for more (up to 60 mA per LED) |
| DIN | Input (the ESP32 drives it) | D25 | Data in. Add a 330 Ω resistor; a 3.3 V to 5 V level shifter makes it reliable |
| GND | Ground | GND |
Suggested wiring for the 30-pin ESP32 DevKit, avoiding flash, input-only and strapping pins. BoardPilot checks it for you as you wire.
This module is sold for 5 V. Its outputs may be 5 V: use a level shifter or a voltage divider on ESP32 inputs.
Good to know
- Each LED draws up to about 60 mA at full white: 30 LEDs need about 1.8 A, more than USB gives. Power the strip from its own 5 V supply and connect the grounds. (Adafruit NeoPixel Überguide, Powering NeoPixels)
- Put a 300 to 500 Ω resistor in the data line and a large capacitor (about 1000 µF) across the strip’s supply. (Adafruit NeoPixel Überguide, Best practices)
- on 3.3 V boards: At 5 V the data input needs at least 0.7 × 5 V = 3.5 V to read HIGH. A 3.3 V board often works but not always: a level shifter (74AHCT125) makes it reliable. (Worldsemi WS2812B datasheet, Electrical characteristics: VIH = 0.7 VDD)
Starter code (Arduino)
void setup() { pinMode(25, OUTPUT); } // DIN
void loop() {
digitalWrite(25, HIGH);
delay(500);
digitalWrite(25, LOW);
delay(500);
}
Sources
- Worldsemi WS2812B datasheet, Supply 3.5 to 5.3 V; data input high level 0.7 × VDD
Try it in 3D in BoardPilot
WS2812B addressable LED strip on other boards: wiring and code
Arduino Mega 2560 R3 Arduino Nano Arduino Uno R3 WeAct Black Pill STM32F411CE ESP32-C3-DevKitM-1 ESP32-S3-DevKitC-1 Nordic nRF52840 DK NUCLEO-F401RE Raspberry Pi Pico 2 Raspberry Pi Pico W Raspberry Pi Pico Teensy 4.1
Learn the basics
Lesson: GPIO: pins in and out Lesson: Hardware basics for software developers GPIO Level shifter Logic level (HIGH and LOW)
Related parts
7-segment 4 digits 0.56" common cathode (12 pins)7-segment digit 0.56" common anode7-segment digit 0.56" common cathodeLCD 16x2 (parallel, 16 pins)LED bar graph 10 segmentsNeoPixel Stick 8 LEDs
Part data: CC BY 4.0, free to reuse with credit to BoardPilot.