Do you know how to use ESP32 smart controller to run WS2811 addressable RGB LED strip?
We have provided a detailed ESP32 pixel programming WS2811 LED strip guide. If you have any trouble in this regard, please read our blog carefully.
1.All materials
DC5V and DC12V Non-waterproof Power supply
DC12V Output
- Voltage: DC 12V
- Current: 33A
- Power Rating: 400W
DC12V Input
- Voltage Range: AC 100V~120V ,200~240V
- Connect the positive and negative terminals of the DC12 power supply to the positive and negative terminals of WS2811 RGB led strip
DC5V Output
- Voltage: DC 5V
- Current: 80A
- Power Rating: 200W
DC5V Input
- Voltage Range: AC 110V/220V (It is dual input supported, switch-selectable)
- Connect the positive and negative terminals of the power supply to the positive and negative terminals of ESP32
Purpose of power supply
- DC12V powers the WS2811 LED strip, and DC5V powers the ESP32
- Connect the negative pole of DC12V power supply to the GND interface of the control board.
- The power supply range of the control board is DC3.3-9V, so the control board is powered separately, and the LED strip is powered by DC12V;
ESP32 Board
Model: ESP32 controller
Operating Voltage: DC5V
Input Voltage (recommended): DC5V,the power supply range of the ESP32 control board is DC3.3-9V, so the control board is powered separately, and the WS2811 LED strip is powered by DC12V;
Digital I/O Pins:The DAT input of the light strip signal is connected to the digital I/O pin (PWM pin is recommended)
Analog Input Pins: 9
Clock Speed: 30 MHz
Programming Interface: USB Type-C
Apply settings:
- The DC3.3/5V interface is the voltage output port of the ESP32 control board. It cannot be connected to the DC12 power supply. Use the DC interface to connect to the power supply.
- The DAT input of the LED strip signal is connected to the digital I/O pin (PWM pin is recommended)
WS2811 RGB LED strip
Type: External IC RGB addressable led strip
Input Voltage: DC12V
Features: No complicated IC chips, rich images can be displayed through the built-in program of the controller
LED Number: 60 LEDs /M
WS2811 LED strip uses an external IC chip, and the LED beads can be independently controlled through a single-line serial protocol, which can achieve a variety of dynamic effects such as flowing water, gradient, marquee, etc.
If you want to know more about WS2811, our blog WS2811 Everything You Need to Know will help you.
In addition to ESP32, other controllers that can drive WS2811 RGB addressable led strips include offline controllers such as K8000C. Users can choose according to the size of the space.
2.WS2811 and ESP32 Wiring Schematic
Note:
1. The current of the ESP32 control board must be <500mA;
2. The current of the WS2811 RGB addressable led strip is too large, please use an external power supply to power the light strip;
3. The DC3.3/5V interface is the voltage output port of the ESP32 control board. It cannot be connected to the power supply. The DC interface is used for connecting the power supply;
4. The power supply range of the control board is DC3.3-9V, so the control board is powered separately, and the light strip is powered by DC12V;
5. The wiring of RGB LED strips is the same as that of RGBW led strips, but the program cannot be shared;
6. The more pixels, the lower the refresh rate;
7. Note that the GPIO of ESP32 is 3.3V logic level, so the GPIO pin needs to be converted to a level before connecting to the light strip signal pin (74HCT125 or MOSFET level conversion).
3.WS2811 and ESP32 Connection Diagram
Tips:
- Connect the data wire from Arduino to DIN
- Please cut off the power before rewiring
4.ESP32 Code Upload
Programming software: Arduino IDE
Library Used: FastLED
LEDsuntech: We can provide you with some commonly used programming codes for your reference
// Define RGB pins
const int redPin = 9; // Red pin connects to PWM pin 9
const int greenPin = 10; // Green pin connects to PWM pin 10
const int bluePin = 11; //The blue pin is connected to PWM pin 11
// Fade speed control (milliseconds)
const int fadeSpeed = 20;
void setup() {
// Set the pin to output mode
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
// Initial state: all off (common anode)
analogWrite(redPin, 255);
analogWrite(greenPin, 255);
analogWrite(bluePin, 255);
}
void loop() {
// Red→Green Gradient
for (int i = 0; i <= 255; i++) {
analogWrite(redPin, i);
analogWrite(greenPin, 255 - i);
analogWrite(bluePin, 255);
delay(fadeSpeed);
}
//Green→Blue Gradient
for (int i = 0; i <= 255; i++) {
analogWrite(redPin, 255);
analogWrite(greenPin, i);
analogWrite(bluePin, 255 - i);
delay(fadeSpeed);
}
// Blue→Red Gradient
for (int i = 0; i <= 255; i++) {
analogWrite(redPin, 255 - i);
analogWrite(greenPin, 255);
analogWrite(bluePin, i);
delay(fadeSpeed);
}
}
5.WS2811 Demonstration Video
In order to let you understand the effect of ESP32 controlling WS2811 addressable led strip more quickly, we have attached a video for your reference.
If WS2811 can only be controlled without a controller, it will be mediocre. However, by using the PWM dimming characteristics of WS2811 and combining it with the intelligent control of ESP32, complex effects such as gradual change and musical rhythm can be achieved.
Please contact us if you need any help on how to control WS2811 LED strips with ESP32.