WS2812B NeoPixel LED
WS2812B NeoPixel LED
Overview
WS2812B (NeoPixel) is an addressable RGB LED that can cascade multiple LEDs through a single data wire, with each LED independently controllable for color. Suitable for ambient lighting, status indication, LED strips, and other applications.
Supported Peripheral Types
| Type | type Value | Description |
|---|---|---|
| NEO_PIXEL | 45 | WS2812B/WS2811 Addressable LED |
Hardware Wiring
| NeoPixel Pin | Connection | Description |
|---|---|---|
| VCC | 5V | Power supply (~60mA per LED at full brightness) |
| GND | GND | Ground |
| DIN | GPIO | Data input (recommend 330Ω series resistor) |
Configuration
Method 1: Web Interface Configuration (Recommended)
Before saving NeoPixel configuration, verify the data pin, LED count, color order, and independent power supply.
Step 1: Navigate to Peripheral Management Page
- Open a browser and navigate to the ESP32 IP address
- After logging in, click Peripheral Configuration in the left menu
Step 2: Add NeoPixel LED Strip Peripheral
Click the Add Peripheral button
Fill in the configuration:
Field Value Description Peripheral ID neopixel1Unique identifier Name RGB LED StripDisplay name Peripheral Type NeoPixel LED (type: 45) WS2812B driver Pin Configuration 16DIN data pin LED Count 81-300 LEDs Global Brightness 500-255 Click Save
Step 3: Verify Configuration
- Find the newly added peripheral in the peripheral list
- Click the Enable toggle
- Use the control panel to send color values (e.g., #FF0000 for red)
⚠️ Important: More than 10 LEDs require an independent 5V power supply; each LED draws ~60mA at full brightness
Method 2: JSON Configuration File Import
Add the following configuration to the peripherals array in data/config/peripherals.json:
{
"id": "neopixel1",
"name": "RGB LED Strip",
"type": 45,
"enabled": false,
"pins": [16],
"params": {
"count": 8,
"brightness": 50
}
}Parameter Description
| Parameter | Description | Range |
|---|---|---|
| count | Number of LEDs | 1-300 |
| brightness | Global brightness | 0-255 |
Peripheral Execution Integration
NeoPixel is controlled via script actions (ACTION_SCRIPT = 15) or CALL_PERIPHERAL (10).
Web Interface Configuration Steps
Create RGB Running Light Effect
- Switch to the Peripheral Execution Management tab
- Click the Add Rule button
- Configure a trigger (e.g., timer trigger, event trigger)
- Add a script action:
- Action Type: Command Script
- Script Content:
PERIPH neopixel1 COLOR #FF0000 DELAY 500 PERIPH neopixel1 COLOR #00FF00 DELAY 500 PERIPH neopixel1 COLOR #0000FF - Click Save
💡 Tip: Use PERIPH commands to control colors, DELAY to control timing
JSON Configuration Example
Script Control Example
{
"targetPeriphId": "",
"actionType": 15,
"actionValue": "PERIPH neopixel1 COLOR #FF0000\nDELAY 1000\nPERIPH neopixel1 COLOR #00FF00\nDELAY 1000\nPERIPH neopixel1 COLOR #0000FF",
"useReceivedValue": false,
"syncDelayMs": 0,
"execMode": 0
}Platform Downlink Control
Send color values via MQTT:
[{"id": "neopixel1", "value": "#FF5500"}]Notes
- Power Supply: Each LED draws up to 60mA at full brightness; 8 LEDs = 480mA; more than 10 LEDs require an independent power supply
- Level Shifting: ESP32 GPIO is 3.3V, WS2812B requires 5V logic; short distances can use direct connection, long lines recommend level shifting
- Series Resistor: Data line should have a 330Ω series resistor to protect GPIO
- Capacitor Filtering: Connect a 100μF capacitor across the power supply to prevent voltage fluctuations
- Maximum Count: Limited by memory and refresh time; recommend a maximum of 300 LEDs per strip
