An LED strip from a 3.3 V pin
A WS2812 strip on 5 V wants its data at 3.5 V or more, and an ESP32 pin tops out at 3.3. One channel of a TXB0108 closes the gap, and a rainbow sketch shows whether it did.
Why the strip is the exception
Most 5 V parts read a 3.3 V HIGH correctly. A WS2812 strip wants 0.7 of its supply: at 5 V, that is 3.5 V, and an ESP32 pin gives 3.3 V.
Only the first LED reads your signal. It then passes a fresh 5 V copy to the next, and so on down the strip. So the whole strip depends on one comparison at pixel one.
Plenty of strips read 3.3 V anyway, which is why the direct wiring is everywhere. It is a margin of minus 0.2 V, and a different strip, a longer wire or a warmer day is enough to lose it.
Wiring
- ESP32 3V3 to VA.
- The strip's +5V to VB.
- GND joining the TXB, the ESP32, the strip and the strip's supply.
- The ESP32's data GPIO to A1, and B1 to the strip's DIN.
- OE: nothing. The board already pulls it up.
![The TXB0108 board at an angle: a black board with the TXB0108 [SPI] title at the top, VA 3V3 and 5V VB at the upper corners, A1 to A8 and B1 to B8 down the edges, and OE and GND at the bottom corners.](/modules/llc/txb-iso.webp)
Why the TXB
The strip reads bits from pulses a fraction of a microsecond long. The TXB drives each edge hard, so the pulse arrives square. A MOSFET board's rising edge is slower, and at these speeds it is marginal. The TXS also works.
Power
A handful of LEDs at low brightness can run from the ESP32's USB 5 V. More than that wants its own 5 V supply — with its ground joined to the ESP32's, or the data means nothing to the strip.
The code
A slow rainbow along the strip. Set DATA_PIN to the GPIO you wired to A1 and PIXELS to the number of LEDs, and every pixel should show a smooth, steady colour.
// Converter wiring for this sketch (TXB0108 board).
//
// ESP32 3V3 -> VA
// Strip +5V -> VB (the strip's own 5 V supply)
// GND -> GND on the TXB, the ESP32, the strip and its supply
// ESP32 GPIO -> A1 B1 -> strip DIN
// OE -> nothing (the board already pulls it up)
//
// Arduino IDE: any ESP32 board. Library: Adafruit NeoPixel, from the
// Library Manager.
#include <Adafruit_NeoPixel.h>
const int DATA_PIN = 4; // the GPIO wired to A1 - change to yours
const int PIXELS = 8; // how many LEDs on your strip
Adafruit_NeoPixel strip(PIXELS, DATA_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.setBrightness(40); // bright enough for a bench, easy on USB power
}
void loop() {
static uint16_t hue = 0;
for (int i = 0; i < PIXELS; i++) {
uint16_t h = hue + i * (65536L / PIXELS);
strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(h)));
}
strip.show();
hue += 256;
delay(20);
}If red and green are swapped, your strip uses a different colour order: change NEO_GRB to NEO_RGB. If the colours jump or flicker, check the ground first — the ESP32, the TXB, the strip and its supply must all share one.
When it does not work
Check that B1 goes to the strip's DIN end, not DOUT — the arrows printed on the strip point away from the input. Then check VB is the strip's 5 V, and that the strip's ground is joined to the ESP32's.
The strip is drawing more than the USB port can give. Keep the brightness low while testing, and power anything more than a handful of LEDs from its own 5 V supply, with its ground joined to everything else.
Look at the ground and the data wire before the converter. A long data wire from B1 to the strip, or a ground that only connects through a thin breadboard jumper, can still upset the first pixel. Keep B1 to DIN short.
It is marginal. The strip's shortest pulse is about 0.4 µs, and the MOSFET board's rising edge takes a similar time on short wires. It may work on the bench and fail with a longer wire. The TXB, or the TXS, is the dependable choice.
Six readings that settle whether a converter is wired right.
Check it with a meter →Edit this page — content/books/llc/an-led-strip-from-3v3.mdx
Questions about this product
See what other owners have asked, and read their solutions.
This page covers several products. Choose yours to see the right discussions.
Discuss this article
Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.