Parts for any of the 3 diagrams below.
You won't need everything at once โ pick the diagram you'll actually build and grab only those parts. Most of this is reusable.
| Part | Cost | What to look for |
|---|---|---|
| ESP8266 board | $4โ6 | NodeMCU v2/v3 or Wemos D1 mini โ both expose every usable GPIO on labelled pins |
| LED strip (12V analog) OR WS2812B (5V addressable) | $5โ25 | 12V strip = simple on/off zones ยท WS2812B = per-LED colour and effects |
| Power supply | $6โ18 | 12V for analog strips (sized to total wattage) ยท 5V 10A for WS2812B runs |
| Relay module (1-channel or 4-channel) | $1โ4 | For 12V strips โ low-level trigger (active-low) is most common |
| Breadboard + jumper wires | $3โ6 | For prototyping. Screw terminals later for permanent installs |
| Level shifter (optional) | $1 | 74HCT245 or similar โ only for long WS2812B runs |
Three builds, one set of parts.
Pick the one that matches what you bought. The relay diagram is the safest place to start โ most beginner mistakes happen when you try to power the LED strip from the ESP8266 itself, and a relay cleanly separates logic from load.
Relay control for 12V LED strip (on/off zones)
โโโโโโโโโโโโโโโโ
12V + โโโโค LED strip โ
โ (12V DC) โ
12V โ โโโโค โ
โโโโฌโโโโโโโโโโโโ
โ
โโโโโโโโดโโโโโโโ
โ Relay โ โ switch side
โ COM โโโโโโโผโโโโ 12V +
โ NO โโโโโโโผโโโโ to strip +
โ NC โ (leave NC unconnected)
โโโโฌโโโโโโโโโโโโ
โ
GND โโโโโโโโโโโโโโ supply GND โโโ ESP8266 GND
โโโโโโโโโโโโโโโโ
ESP 5V โโโโโโค Relay coil โ
โ VCC โ
GPIO D1 โโโโโโค IN โ โ most modules are active-low:
โ GND โโโโโโโโผโโโ ESP8266 GND
โโโโโโโโโโโโโโโโ
Logic (3.3V GPIO) on the left is fully isolated from the load (12V strip) on the right. Drive the GPIO HIGH (or LOW, depending on the module) and the relay clicks, the strip lights up. Use one relay per zone โ a 4-channel relay module gives you four on/off zones for ~$3.
Direct 5V WS2812B addressable strip
ESP8266 (NodeMCU) Power supply (5V)
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
โ โ โ โ
D2 โโโค GPIO4 (DIN) โโโโโโบ strip DIN โ โ
โ โ โ โ
GND โโโโค GND 5V โโโโโ โโโค 5V + +5V โโโบ strip 5V
โโโโโโโโโโโโโโโโ โ โ โ โ
โโโโโโโโโโโดโโค GND GND โโโบ strip GND
โโโโโโโโโโโโโโโโ
Tiny strips (โค60 LEDs, <1m): 5V line can come from ESP8266 VIN pin
Larger strips: 5V must come from a 5V supply sized to the strip
Common ground is non-negotiable โ strip GND, supply GND, and ESP8266 GND must be tied together or the data line glitches (random colours, half-lit pixels). Data pin choices below.
Powering the ESP8266 itself (USB vs 5V rail)
USB charger (5V) โโโโโโโโโโโโโโโโ โ +5V โโโโโโบ ESP8266 USB port (simplest, recommended) โ GND โโโโโโบ ESP8266 GND โโโโโโโโโโโโโโโโ Alternative: 5V regulated rail โโโโโโโโโโโโโโโโ โ 5V rail โโโโโโบ ESP8266 VIN pin (5V only โ never 12V into VIN!) โ GND โโโโโโบ ESP8266 GND โโโโโโโโโโโโโโโโ
On a NodeMCU, the VIN pin is 5V only, not 12V. If your strip runs on 12V, power the ESP8266 separately from a USB phone charger or a 5V buck converter. Don't be tempted to feed 12V into VIN "to share one supply" โ the on-board regulator will run very hot and is not rated for that.
GPIO pins that actually work.
This is the table to keep open in a second tab while you wire. D1/D2/D5/D6 are the everyday safe pins; D4 (GPIO2) is the data line for WS2812B boards with onboard LEDs but has boot-time quirks โ details below.
| NodeMCU label | ESP8266 GPIO | Best use |
|---|---|---|
| D1 | GPIO5 | Relay IN ยท general output ยท safe at boot |
| D2 | GPIO4 | Relay IN ยท I2C SDA ยท safe at boot |
| D5 | GPIO14 | Relay IN ยท SPI CLK ยท safe at boot |
| D6 | GPIO12 | Relay IN ยท safe at boot |
| D7 | GPIO13 | DMX data ยท safe at boot |
| D4 | GPIO2 | WS2812B data (default for most FastLED sketches) ยท safe at boot on most boards but must be pulled HIGH externally for a few ฮผs |
| D3 | GPIO0 | Flash mode โ avoid for general use |
| D8 | GPIO15 | Boot mode โ must be LOW at boot, conflict-prone with pull-ups. Avoid. |
What beginners actually get wrong.
Save yourself an hour at the workbench โ these are the four mistakes I see in every beginner troubleshooting thread.
The 5V pin on a NodeMCU can source roughly 500 mA before the on-board regulator overheats; a single 5m WS2812B strip can pull 18 A at full white. Use a dedicated supply sized to the strip.
If the strip's GND isn't tied to the ESP8266's GND, the data line has no reference and colours will glitch or LEDs won't light at all.
NodeMCU's VIN is rated for 5V. 12V into VIN cooks the regulator. Use USB or a buck converter.
Past ~1m, the 3.3V GPIO signal gets eaten by the strip's input capacitance. A 74HCT245 level shifter or a simple 5V pull-up on the data line fixes the glitching.
Wire your first strip in 20 minutes.
Use Diagram 1 (relay + 12V strip) for this build โ it's the cleanest starting point and the most common "is this even working?" sanity check.
Connect relay VCC โ ESP8265 5V (VIN pin) and relay GND โ ESP8266 GND. Don't connect IN yet.
12V supply + โ relay COM. Relay NO โ strip +. 12V supply โ โ strip โ (and to ESP8266 GND for a common ground).
ESP8266 D1 โ relay IN. Flash the blink example with D1 swapped in โ relay should click every second and the strip should blink with it. If nothing happens, try driving IN LOW: most cheap modules are active-low.
Swap the blink sketch for a web server sketch that toggles D1 from a button on 192.168.4.1 โ now the strip is phone-controlled over WiFi. That's the basic skeleton every bigger build is built on.
If you'd rather skip the wiring guesswork.
If you'd rather skip the wiring guesswork, the ESP8266 Event Lighting Control pack I sell on Kachang Sia includes the same wiring diagrams, redrawn step by step, plus the ready-to-flash firmware โ AP web control, phone WiFi, and DMX sync in one $19 download.
๐ See the ESP8266 Event Lighting Pack ($19)Quick answers before you start.
Can the ESP8266 power the LED strip directly?
No, not for any practical strip. The ESP8266's 3.3V GPIO pins can only source tens of milliamps, and even the 5V pin on a NodeMCU tops out around 500 mA before the on-board regulator runs too hot. An LED strip needs amps โ use a separate power supply sized for the strip, and let the ESP8266 only control what the supply does (via relay, or via the data line for addressable strips).
Do I need a level shifter for WS2812B data?
Often yes for reliable colour on long runs. WS2812B expects a 5V data signal but the ESP8266's GPIO is 3.3V. Short strips (under ~1 m, low brightness) usually work fine without one. For longer runs, a 74HCT245 level shifter or a 5V pull-up resistor on the data line fixes glitches and colour errors caused by the data signal sagging.
Which GPIO pins are safe to use on an ESP8266?
D1 (GPIO5), D2 (GPIO4), D5 (GPIO14), D6 (GPIO12) and D7 (GPIO13) are the safest general-purpose pins and work for relays, sensors, and most protocols. D4 (GPIO2) is the data line on WS2812B boards with onboard LEDs and is fine for short strips. Avoid D3 (GPIO0) โ it's used for flash mode โ and be careful with D8 (GPIO15), which must be pulled LOW at boot and conflicts with many sensors.