ESP8266, a Wi-Fi microcontroller, is replacing some old controllers. How to control addressable WS2815 LED strips with ESP8266?
Follow this article to learn how to use the ESP8266 controller flexibly, from WS2815 Led Strip power supply to ESP8266 programming.
1. Materials Required
Power Supply
Output
- Voltage: DC5V
- Current: Up to 40A
- Power Rating: 200W
Input
- Voltage Range: AC 110V/220V (dual input supported, switch-selectable)
- Application: Consumer electronics, low-power devices, special scenarios, mainly used for led strips
- Note that this is non- waterproof power supply. If you need waterproofing, please replace it.
Power Supply
Output
- Voltage: DC12V
- Current: Up to 33.3A
- Power Rating: 400W
Input
- Voltage Range: AC 110V/220V (dual input supported, switch-selectable)
- Applications: lighting systems, industrial equipment, 3D printers, NAS hard disk power supply, and vehicle electrical appliance modification.
For this setup:
- DC5V Power to the the ESP8266 from the power supply (5 volts/GND wire) and DC12V to power the WS2815 Led strip.
- Sufficient current for many Led strips
- Industrial-grade reliability and good heat dissipation and ventilation
ESP8266 Control Board
Model: ESP8266
Operating Voltage: 3.3V-5V
Input Voltage (recommended): ESP8266 has two voltages, one is the external power supply port is 5V, Type-C5V, output pin 3.3V
Digital I/O Pins: 5
Maximum operating pixels: 800-1000 pixels
Wireless connection: Built-in Wi-Fi function, supports STA (client), AP (hotspot) and STA+AP mixed mode.
Application of ESP8266: With Wi-Fi function and strong cost performance, ESP8266 is widely used in the Internet of Things and smart home
Programming Interface: USB Type-C
Use in this setup:
- The ESP8266 controller is used as a controller to send digital data signals to the WS2815 LED strip.
- The LED strip is connected to a DC12V power supply and the controller is connected to a 5V power supply.
- It should be noted that the GPIO of the ESP8266 is a 3.3V logic level, so the GPIO pins need to be level-converted before connecting to the LED strip signal pins. The “D1” interface of the WS2815 LED strip is connected to the 5V data output pins (such as HU1-HU4) in the level converter through a wire, and then connected to the digital I3 interface through a 3.3V (LU1-LU4) interface. The positive pole of the 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. “B1” does not need to be connected
WS2815 LED Strip
Type: Built-in IC, RGB LED built-in WS2815 control chip, with break continue function
Voltage: DC12V
Communication protocol: two-wire, 8-bit, 800Hz
Features: DC12V power supply, compared with 5V led strip (such as WS2812B), the transmission distance is increased by 3 times
LED density: 60 LEDs/meter
Accessories & Tools
- Connecting Wires: Use appropriate gauge, e.g., 18–22 AWG,18-22AWG is the wire diameter that meets international standards
- Logic-Level Shifter: Must use 4-way level converter
2. Wiring Schematic
Below is the connection diagram of how to control WS2815 using ESP8266 controller
Note:
1. The control board current of ESP8266 is less than 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 interface is the voltage output port of the control board and cannot be connected to the power supply;
4. The light strip is powered by DC12V, and the power supply range of the control board is DC3.3-9V, so the control board is powered by DC5V alone;
5. It should be noted that although the wiring of RGB is the same as RGBW, the programs cannot be shared;
7. Note that the GPIO of ESP8266 is 3.3V logic level, so the GPIO pin needs to be converted and then connected to the signal pin of the light strip.
3. Connection Diagram
Tips:
- Short, direct data wire from ESP8266 to DIN
- Safety terminal connection on power supply
- Always disconnect power before rewiring
4. Code Upload
Software: Arduino IDE
Library Used: FastLED
We have prepared a wealth of lighting effects programming code solutions for you, and the LEDSuntech engineer team is ready to answer technical questions at any time.
#include
#define LED_PIN 19 // LED strip data pin
#define NUM_LEDS 80 // Number of LEDs
#define BRIGHTNESS 128 // Initial brightness (0-255)
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB // Most WS2812s are GRB order
CRGB leds[NUM_LEDS];
// Effect mode enumeration
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 color light spot at the current position
leds[pos] = CHSV(hue, 255, 255);
// Move position
pos = (pos + 1) % NUM_LEDS;
// Change hue
hue += 3;
FastLED.show();
delay(30);
}
// Full color blinking effect
void blinkEffect() {
static bool lightsOn = false;
static uint8_t hue = 0;
if(lightsOn) {
// Random color for all lights
fill_solid(leds, NUM_LEDS, CHSV(hue, 255, 255));
hue += 5;
} else {
// All lights off
fill_solid(leds, NUM_LEDS, CRGB::Black);
}
lightsOn = !lightsOn;
FastLED.show();
delay(lightsOn ? 200 : 800); // On for 200ms, off for 800ms
}
// Marquee effect
void marqueeEffect() {
static uint8_t hue = 0;
static int position = 0;
static int tailLength = 15;
// Gradual extinguishing
fadeToBlackBy(leds, NUM_LEDS, 20);
// Create a marquee
leds[position] = CHSV(hue, 255, 255);
// Create a gradient tail
for(int i = 1; i 30000) {
currentEffect = (currentEffect + 1) % EFFECT_COUNT;
lastEffectChange = millis();
FastLED.clear();
FastLED.show();
}
// Execute the 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 >= '0' && c <= '2') {
currentEffect = c - '0';
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
This video will fully demonstrate how to use ESP8266 to control the light effect changes of WS2815 LED strip.
After reading this article, I believe you have a better understanding of the ESP8266 controller, and I believe you must have started brainstorming! It can easily achieve the diverse effects of WS2815 programmable LED strips. The Suntechlite engineering team can provide a complete technical solution from software development.