How to Program WS2813 Addressable LED Strips with ESP32

I believe you are definitely familiar with WS2813 addressable led strips, right? But have you ever tried to drive it with an EPS32 controller?

How to program WS2813 addressable LED strips with ESP32?

When WS2813 RGB addressable led strips meet ESP32, what kind of lighting effects will they bring? Please follow our blog to see.

1.What materials are required

DC5V Power Supply

DC5V Output

  • Voltage: DC 5V
  • Current: Up to 80A
  • Power Rating: 200W

DC5V Input

  • Voltage Range: AC 110V/220V (dual input supported, switch-selectable)
Arduino 5V LED Power Supply
           DC5V  Power supply

Setup:

  • Powered for the WS2813 RGB LED strip 
  • Provide enough current to allow the LED strip to run farther
  • Good and reliable ventilation and heat dissipation allow you to get twice the result with half the effort

The power supply is an important component for powering the LED strip and ESP32. How to choose the right model requires checking the voltage and power. The first thing to look at is the voltage. The voltage must match the input voltage marked on the device exactly. If you ignore this and connect the wrong voltage, the device will not work at best, or even burn out.

When choosing power, you need to calculate the total power consumption of the device and reserve a margin. Add up the rated power of all electrical devices such as lamps. It is recommended to choose a power supply that is 20%-30% higher than the total. If the margin is insufficient, the power supply will overheat or even fail to work properly, but if you blindly pursue high power, it will cause unnecessary waste.

ESP32 Board

22222
        ESP32 Control Board Area Pin Introduction

Model: ESP32
Operating Voltage: 5V
Input Voltage (recommended): DC5V,Control board current <500mA.
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

Using tips:

  • The Esp32 controller sends digital data signals to the RGB led  strip
  • The control board power supply range is DC3.3-9V, so the control board is powered by DC5V alone.
  • GPIO34~39 are only used for input, not output.

WS2813 RGB led strip

DA3 5V WS2813
WS2813 RGB LED Strip

Type: WS2813 Addressable RGB led strip
Input Voltage: 5V DC
Features: WS2813 built-in IC, individual control makes the lighting more delicate and the picture more dynamic.
LED Density: 60 leds/m

WS2813 is chosen by more and more users for its breakpoint resuming, high integration and strong anti-interference ability. It is widely used in scenes such as LED luminous characters, guardrail tubes, soft and hard light strips, etc.

Its high color consistency and programmable characteristics are suitable for shopping mall advertising screens, building outline lighting and holiday decorations. In addition, WS2812 and WS2815 with the same protocol are also often used for decoration. If you want to know the difference between them, please check the blog WS2812 VS WS2813 VS WS2815, which will help you solve the problem.

2.ESP32 and WS2813 Wiring Schematic

The wiring diagram of LEDSuntech is shown below:

esp32 WS2813 Schematic diagram
How to Control WS2813 LED Strip with ESP32 Wiring Diagram

Note:

1. The current of the ESP32 control board is <500mA;

2. The current of the light 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 by DC5V alone;

5. The wiring of RGB led strips are the same as that of RGBW led strips, but the programs cannot be shared;

6. The more points, 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.ESP32 and WS2813 Connection Diagram

esp32 WS2813 connect
How to Control WS2813 LED Strip with ESP32 LEDSuntech

Using Tips:

  • Direct data wire from Arduino to DIN
  • The DC3.3/5V interface is the voltage output port of the control board and cannot be connected to a power source. If connected to a power source, there is a risk of damage.
  • Please keep disconnect power before rewiring

4. ESP32 Code Upload

Software: Arduino IDE is used

Library Used: FastLED

LED SunTech : ESP32 can make the LED strip emit different lights by setting the code of various light changing effects. If you need technical support, please feel free to contact us

				
					// 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 &lt;= 255; i++) {
    analogWrite(redPin, i);
    analogWrite(greenPin, 255 - i);
    analogWrite(bluePin, 255);
    delay(fadeSpeed);
  }
  
  //Green→Blue Gradient
  for (int i = 0; i &lt;= 255; i++) {
    analogWrite(redPin, 255);
    analogWrite(greenPin, i);
    analogWrite(bluePin, 255 - i);
    delay(fadeSpeed);
  }
  
  // Blue→Red Gradient
  for (int i = 0; i &lt;= 255; i++) {
    analogWrite(redPin, 255 - i);
    analogWrite(greenPin, 255);
    analogWrite(bluePin, i);
    delay(fadeSpeed);
  }
}
				
			

5.WS2813 Demonstration Video 

The following video allows you to more intuitively experience the intelligent effect of combining WS2813 and ESP32 controller.

ESP32 is becoming more and more popular as a high-performance, low-power microcontroller. The SPI interface of ESP32 can accurately transmit the timing signals required by WS2813 at a rate of 800Kbps, ensuring smooth lighting effects without lag.ESP32 also supports complex lighting effects, whether it is gradient, meteor, or music rhythm, etc., you can customize the timing and color change mode through code, giving full play to the single-point addressable characteristics of WS2813.

Of course, if you prefer other colorful light strip controllers, we can also provide you with detailed information, such as the offline controlled K1000C and K8000C,please feel free to contact me if anything Ledsuntech can help you.

Feel Free To Contact Us

We will reply your email within 12 hours.

Ask For A Quote