How to Control WS2818 LED Strips with ESP32

Suntech Lite is a top manufacturer and supplier that focuses on pixel LED strips and LED neon lights.

As a microcontroller, ESP32 has significant advantages over traditional large-scale conventional controllers in many aspects. For example, it can support multiple low-power modes. ESP32 has built-in multiple hardware-level security mechanisms, including secure boot and Flash encryption.

But how to control WS2818 LED strips with ESP32? Here Suntechlite provides detailed instructions on how to wire and use it.

1.Materials Required

DC5V and DC12V Power Supply

power supply 5V
DC5V Power supply

Output

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

Input

  • Voltage Range: AC 110V/220V (dual input supported, switch-selectable)
12V
    DC12V Power supply

Output

  • Voltage: DC 12V
  • Current: 33A
  • Power Rating: 400W

Input

  • Voltage Range:   AC100~120V/200~240V 

Power usage tips

  • Powered for the led strip,the positive pole of the light strip is connected to the positive pole of the DC12V power supply, and the negative pole is connected to the negative pole of the DC12V power supply
  • Provide enough current to allow the LED strip to run farther
  • Safe low voltage, ensuring personal safety

ESP32 Board

ESP32
ESP32 Control Board Area Pin Introduction

Model: ESP32
Operating Voltage: DC5V
Input Voltage (recommended): DC5V,the control board power supply range is DC3.3-9V, so the control board is powered by DC5V alone
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

Tips for using ESP32:

  • The Esp32 controller sends digital data signals to the WS2818 LED strip
  • Built-in program provides rich lighting modes for WS2818 RGB colorful light strip
  • The GPIO of ESP32 is 3.3V logic level, so the GPIO pin needs to be level converted and then connected to the signal pin of the light strip (74HCT125 or MOSFET level conversion

WS2818 LED strip

DA5 12V WS2818
WS2818 LED Strip

Type: External IC Addressable RGB led strip
Input Voltage: DC12V 
Features: The unique external IC structure makes heat dissipation more convenient, and the programmable IC makes the LED strip light rich and varied
LED Density: 60 LEDs/m

WS2818 RGB led strip has dual signal transmission design. When a single LED or control chip is damaged, the subsequent lamp beads can still work normally, avoiding overall failure due to local failure, and significantly improving system stability. 12V DC voltage power supply reduces energy consumption and heat generation, with a power range of 7.2W/m to 14.4W/m, it can adapt to different length requirements, and supports a shear design of 3 lamps per group, which is flexible to install.Whether it is used in hotels or KTVs, its colorful effects can be used to create an atmosphere and enhance customer experience.

In addition to WS2818, our TM1934 RGB addressable led strip and WS2815 RGB addressble led strip are dual signal. If you need to know more parameters, please check the link

2.ESP32 and WS2818 Wiring Schematic

Here’s a schematic wiring diagram from Suntechlite,for your reference:

ESP32 WS2818 Schematic diagram
How to Control WS2818 LED Strip with ESP32 Wiring Diagram

Note:

1. The current of the 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 ESP 32 control board, which 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 addressable RGB is the same as that of addressable RGBW, 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 WS2818 Connection Diagram

ESP32 WS2818 connect picuture
How to Control WS2818 LED Strip with ESP32 LEDSuntech

Tips:

  • Short, direct data wire from Arduino to DIN
  • Secure terminal connections on the power supply
  • Always disconnect power before rewiring

4.Code Upload

Software: Arduino IDE

Library Used: FastLED

Suntechlite :In addition to providing wiring diagrams, our engineering team can also provide programming codes for various lighting effects, as shown below

				
					#include 

#define LED_PIN     19     // Light strip data pin
#define NUM_LEDS    80    // LED quantity
#define BRIGHTNESS  128   // Initial brightness (0-255)
#define LED_TYPE    WS2812B
#define COLOR_ORDER GRB   // Most WS2812 are GRB sequential

CRGB leds[NUM_LEDS];

// Effect mode example
enum Effects {
  EFFECT_FLOW,
  EFFECT_BLINK,
  EFFECT_MARQUEE,
  EFFECT_COUNT
};

uint8_t currentEffect = EFFECT_FLOW;
unsigned long lastEffectChange = 0;
unsigned long lastUpdate = 0;

void setup() {
  delay(3000); // safety delay
  FastLED.addLeds(leds, NUM_LEDS);
  FastLED.setBrightness(BRIGHTNESS);
  Serial.begin(115200);
}

// Full color water effect
void flowEffect() {
  static uint8_t hue = 0;
  static uint8_t pos = 0;
  
  // Gradually turn off all LEDs
  fadeToBlackBy(leds, NUM_LEDS, 10);
  
  // Set a colored light spot at the current position
  leds[pos] = CHSV(hue, 255, 255);
  
  // move location
  pos = (pos + 1) % NUM_LEDS;
  
  // change hue
  hue += 3;
  
  FastLED.show();
  delay(30);
}

// Full color flashing effect
void blinkEffect() {
  static bool lightsOn = false;
  static uint8_t hue = 0;
  
  if(lightsOn) {
    // Random color of full light strip
    fill_solid(leds, NUM_LEDS, CHSV(hue, 255, 255));
    hue += 5;
  } else {
    // All off
    fill_solid(leds, NUM_LEDS, CRGB::Black);
  }
  
  lightsOn = !lightsOn;
  FastLED.show();
  delay(lightsOn ? 200 : 800); // 亮200ms,灭800ms
}

// Marquee effect
void marqueeEffect() {
  static uint8_t hue = 0;
  static int position = 0;
  static int tailLength = 15;
  
  // Gradual fading
  fadeToBlackBy(leds, NUM_LEDS, 20);
  
  // Create a Marquee
  leds[position] = CHSV(hue, 255, 255);
  
  // Creating a gradient tail
  for(int i = 1; i  30000) {
    currentEffect = (currentEffect + 1) % EFFECT_COUNT;
    lastEffectChange = millis();
    FastLED.clear();
    FastLED.show();
  }
  
  //Execute current effect
  switch(currentEffect) {
    case EFFECT_FLOW:    flowEffect();    break;
    case EFFECT_BLINK:   blinkEffect();   break;
    case EFFECT_MARQUEE: marqueeEffect(); break;
  }
  
  // Brightness control (optional)
  // adjustBrightness();
}

// Optional: Switch effects via serial port commands
void serialEvent() {
  while(Serial.available()) {
    char c = Serial.read();
    if(c &gt;= '0' &amp;&amp; c &lt;= &#039;2&#039;) {
      currentEffect = c - &#039;0&#039;;
      FastLED.clear();
      FastLED.show();
    }
  }
}

// Optional: Brightness adjustment function
void adjustBrightness() {
  int potValue = analogRead(A0); // Connect the potentiometer to A0
  int newBrightness = map(potValue, 0, 1023, 0, 255);
  FastLED.setBrightness(newBrightness);
}
				
			

5.Demonstration Video

SunTechlite also provides a video of ESP32 controlling WS2818 LED strip for your reference.

The SP32 controller, with its powerful processing power, dual-core architecture, Wi-Fi/Bluetooth functions and rich hardware interfaces, combined with the programmable features of the WS2812 RGB light strip, can achieve many creative ways to play that break through traditional lighting effects.As more and more LED products are flooding into the market, people are also troubled by How To Choose The Right Addressable LED Strip. But don’t worry, we provide you with a one-stop service.

Suntechlite has a professional engineering team to provide you with technical support. If you need support, please feel free to contact us.

Share To

Enquiry