Skip to content

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 ​

Typetype ValueDescription
NEO_PIXEL45WS2812B/WS2811 Addressable LED

Hardware Wiring ​

NeoPixel PinConnectionDescription
VCC5VPower supply (~60mA per LED at full brightness)
GNDGNDGround
DINGPIOData input (recommend 330Ω series resistor)

Configuration ​

Before saving NeoPixel configuration, verify the data pin, LED count, color order, and independent power supply.

Step 1: Navigate to Peripheral Management Page ​

  1. Open a browser and navigate to the ESP32 IP address
  2. After logging in, click Peripheral Configuration in the left menu

Step 2: Add NeoPixel LED Strip Peripheral ​

  1. Click the Add Peripheral button

  2. Fill in the configuration:

    FieldValueDescription
    Peripheral IDneopixel1Unique identifier
    NameRGB LED StripDisplay name
    Peripheral TypeNeoPixel LED (type: 45)WS2812B driver
    Pin Configuration16DIN data pin
    LED Count81-300 LEDs
    Global Brightness500-255
  3. Click Save

Step 3: Verify Configuration ​

  1. Find the newly added peripheral in the peripheral list
  2. Click the Enable toggle
  3. 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:

json
{
  "id": "neopixel1",
  "name": "RGB LED Strip",
  "type": 45,
  "enabled": false,
  "pins": [16],
  "params": {
    "count": 8,
    "brightness": 50
  }
}

Parameter Description ​

ParameterDescriptionRange
countNumber of LEDs1-300
brightnessGlobal brightness0-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

  1. Click Peripheral Execution in the left menu
  2. Click the Add Rule button
  3. Configure a trigger (e.g., timer trigger, event trigger)
  4. 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
  5. Click Save

💡 Tip: Use PERIPH commands to control colors, DELAY to control timing


JSON Configuration Example ​

Script Control Example ​

json
{
  "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
}

Send color values via MQTT:

json
[{"id": "neopixel1", "value": "#FF5500"}]

Notes ​

  1. Power Supply: Each LED draws up to 60mA at full brightness; 8 LEDs = 480mA; more than 10 LEDs require an independent power supply
  2. Level Shifting: ESP32 GPIO is 3.3V, WS2812B requires 5V logic; short distances can use direct connection, long lines recommend level shifting
  3. Series Resistor: Data line should have a 330Ω series resistor to protect GPIO
  4. Capacitor Filtering: Connect a 100μF capacitor across the power supply to prevent voltage fluctuations
  5. Maximum Count: Limited by memory and refresh time; recommend a maximum of 300 LEDs per strip

FastBee | fastbee.cn