esp32.diy

ESP32 LED Matrix: What It Is, Wiring, Code and Pitfalls

Nov 29, 2026 · 7 min read · Intermediate

ESP32 LED Matrix: What It Is, Wiring, Code and Pitfalls
TL;DR An ESP32 LED matrix is a grid of LEDs driven by an ESP32, usually through a library such as ESP32-HUB75-MatrixPanel-DMA for HUB75 panels or PxMatrix for P10-style panels. Start by matching your panel's scan type and driver chips to a supported library, then wire power and data carefully and run a test sketch before writing your own animation code.
Common panel familiesHUB75/HUB75E RGB panels and P10-style 64x32 panels
HUB75 library board supportESP32, ESP32-S2, ESP32-S3, ESP32-P4; S31 experimental
HUB75 DMA enginesI2S LCD mode on ESP32/S2; LCD_CAM + GDMA on S3; PARLIO + GDMA on P4
Common driver chipsFM6124, ICN2037, SM16208, DP5125D
Scan examples64x32 indoor is 1/16 scan; 64x64 indoor is 1/32 scan
Rendering patternOne long-running render task with a request queue

What is an ESP32 LED matrix?

An ESP32 LED matrix is a grid of LEDs that an ESP32 controls as a display. In practice you rarely drive every LED directly: the panel carries driver chips, and the ESP32 streams pixel data to them. Two common families show up in the sources: HUB75/HUB75E RGB panels, handled by the ESP32-HUB75-MatrixPanel-DMA library, and P10-style 64x32 panels, shown with the PxMatrix library. The HUB75 library uses hardware DMA so pixel data streams without using CPU resources, and it supports variable color depth up to 24-bit TrueColor depending on panel size and refresh rate. It is also Adafruit GFX compatible, or can run with a lighter GFX implementation or no GFX library at all.

People phrase the search in different ways. Whether you type esp32 with led matrix, esp32 and led matrix, or esp32 led matrix project, the core job is the same: choose a panel, match it to a supported library, wire it correctly, and write code that keeps the display refreshed.

Which ESP32 boards and LED matrix panels are compatible?

Not every ESP32 can drive every panel. The HUB75 DMA library lists the following support:

ESP32 variant DMA engine Status
ESP32 (original, e.g. ESP-WROOM-32) I2S parallel LCD mode Supported
ESP32-S2 I2S parallel LCD mode Supported
ESP32-S3 LCD_CAM + GDMA Supported; supports Octal PSRAM via SPIRAM_DMA_BUFFER
ESP32-P4 PARLIO TX + GDMA Supported
ESP32-S31 PARLIO TX + GDMA Experimental

The library explicitly does not support ESP32-C2, ESP32-C3, ESP32-C5, ESP32-C6, or ESP32-H2. Those parts either lack a parallel LCD/PARLIO DMA engine, or in the C6/H2 case PARLIO cannot control continuous transaction lengths in a hardware loop.

Panel scan type matters just as much as the board. The library works out of the box with standard two-scan HUB75 panels, where two rows are updated at the same time. It says 64x32 indoor panels are 1/16 scan and 64x64 indoor panels are 1/32 scan. Non-two-scan panels, including 1/4, 1/5, 1/6, 1/8, 1/10, 1/16 four-scan and 1/2 or 1/4 eight-scan modules, need the VirtualMatrixPanel_T mapping. If the mapping is wrong, the image will not look like the test pattern.

Before buying a panel, the library gives a blunt warning: ask the seller to confirm the panel is not an S-PWM chip and uses standard shift-register driver chips such as FM6124, ICN2037, SM16208, or DP5125D. New driver chips are released often, so check before purchasing. For P10-style panels, the PxMatrix example in the sources is written around a 64x32 panel and includes an ESP32 pin block with P_LAT 22, P_A 19, P_B 23, P_C 18, P_D 5, P_E 15, and P_OE 16. Treat those as example pins, not a universal wiring rule.

How do you get started with an ESP32 LED matrix?

Start with a known-good panel and a test sketch before you write your own graphics code. The HUB75 library README is organized around three steps: library installation, wiring the ESP32 to the panel, and running a test sketch. Follow those steps in order. The library works with Arduino and ESP-IDF 4.x, 5.x, or 6.x, and it can use Adafruit GFX, GFX_Lite, or no GFX library. That gives you a choice: use GFX if you want familiar drawing primitives, or go lean if you only need raw pixel control.

For a P10 panel with PxMatrix, the example sets the matrix size and pins before creating the display object:

#define P_LAT 22
#define P_A 19
#define P_B 23
#define P_C 18
#define P_D 5
#define P_E 15
#define P_OE 16
PxMATRIX display(64,32,P_LAT, P_OE,P_A,P_B,P_C,P_D);

The same example sets display_draw_time to 10 and notes that 30-70 is usually fine, but if it is too large the ESP will crash. It also exposes build-time options for color depth, SPI frequency, and double buffering. Those are useful tuning knobs, but change one at a time so you know what caused the improvement or the failure.

A sensible first test is a static pattern: fill the screen, draw a border, or show a few blocks of color. Once that is stable, move to text or icons, then animation. If the static test is wrong, animation code will only make the problem harder to see.

How should you structure code for static images and animations?

Static images and animations are different code problems, and the FreeRTOS answer in the sources is to use one long-running render task with its own state and a request queue. The main task handles user interaction and sensor input. When it wants a new display, it queues a request to the render task. The render task polls the queue; if a new request arrives, it switches work. If not, it continues the current action. That avoids starting and stopping a task for every icon or animation, which the source describes as nothing but pain.

The render task should keep its own little state machine. A static action can draw once and then set itself to idle, so the task does not complete. An animation action can render one frame, advance its state, and repeat. The queue-polling part of the source pattern looks like this:

while (1) {
    // new work to do?
    reqnew = dequeue_request_nowait(&render_task_work);
    // yes, release old and setup new work
    if (reqnew != NULL) {
        // release old request block to free queue
        if (reqcur != NULL)
            enqueue_request(&render_task_free,reqcur);
        // setup new request
        reqcur = reqnew;
        init = 1;
    }
    else
        init = 0;

After that block, the source handles the current work with a switch on reqcur->req_action, then calls wait_for_frame_start(timeout) to prevent infinitely fast rendering. The source notes that the same effect could be achieved with a timeout on a blocking dequeue. For animations, separate display_animation_frame from advance_animation_state so the system stays responsive. Reset the state to zero or use modulo to loop the animation.

What are the common pitfalls with an ESP32 LED matrix?

Most ESP32 LED matrix failures come from a small set of avoidable issues.

Pitfall What happens What to do
Buying an unsupported panel The library may not drive it correctly, or at all Ask the seller for standard shift-register driver chips, not S-PWM
Wrong scan mapping Image is scrambled, split, or offset Use VirtualMatrixPanel_T for non-two-scan panels and check the pixel mapping test
Unsupported ESP32 variant No parallel LCD/PARLIO DMA engine Use a supported ESP32, S2, S3, or P4 board
Draw time too high The ESP can crash Keep display_draw_time in a safe range; the example uses 10 and notes 30-70 is usually fine
Noisy image SPI frequency may be too high Reduce PxMATRIX_SPI_FREQUENCY
Double buffering on a small board RAM use doubles Enable PxMATRIX_double_buffer only if you have room
Too many color levels Update speed drops Lower PxMATRIX_COLOR_DEPTH if refresh is too slow
Starting and stopping render tasks Old task must terminate before new one starts Use one render task with a request queue
Confusing LCD with LED matrix A raw dot-matrix LCD needs AC drive, not simple LED matrix drive Use the right drive method or a dedicated LCD driver chip

The LCD note is worth repeating because salvaged panels cause confusion. The source explains that a raw dot-matrix LCD is driven like a matrix LED display in some ways, but the LCD elements are organized into backplanes and need an AC waveform. You toggle two GPIO pins in phase or out of phase to energize or de-energize a segment, and large LCDs usually need a driver chip. That is not the same as sending pixel data to a HUB75 LED panel.

What ESP32 LED matrix projects can you build?

With a working panel and a render task, the practical projects are straightforward. The sources show static icons, animations, and weather icons. A static icon is a finite pattern: iterate over the LEDs and set them on or off. An animation is the same idea in a loop, with the render task advancing one frame at a time until the app state changes. A weather display is a natural extension because it combines icons with periodic updates.

That covers the intent behind esp32 led matrix project searches: you are not just buying a panel, you are building a small display system. The same setup answers esp32 with led matrix and esp32 and led matrix searches, because the wording changes but the hardware and code path do not. Pick a supported board, confirm the panel type, run the library test, then build the smallest display you actually need. Add Wi-Fi, sensors, or a web UI only after the matrix is stable.

Frequently asked questions

Can an ESP32 drive a 64x32 LED matrix?

Yes. The HUB75 library lists 64x32 indoor panels as two-scan 1/16 scan panels, and the PxMatrix example uses a 64x32 P10 panel. Match the library and mapping to the exact panel.

Which ESP32 boards does the HUB75 DMA library not support?

ESP32-C2, C3, C5, C6, and H2 are not supported. The library lists ESP32, S2, S3, and P4 as supported, with S31 experimental.

Why is my LED matrix image scrambled?

The scan type or pixel mapping is probably wrong. Standard two-scan panels work out of the box; non-standard panels need VirtualMatrixPanel_T mapping and a pixel mapping test.

How should I handle animations with FreeRTOS?

Use one long-running render task with a request queue. The main task queues a new action; the render task switches to it, renders frames, and advances its own animation state.

Is a raw dot-matrix LCD the same as an LED matrix?

No. A raw LCD dot-matrix panel needs an AC waveform and often a dedicated driver chip; an LED matrix panel uses LED driver chips and pixel data.

Bottom line

An ESP32 LED matrix is a practical display project when you treat panel compatibility as the first design decision. Choose a supported board, confirm the driver chips and scan type, run the library test sketch, and keep rendering in one long-running task. The pitfalls are predictable: wrong panel, wrong mapping, too much draw time, or too little RAM.

Sources

stackoverflow.comHow to use render task(s) for LED matrix with ESP32 FreeRTOSstackoverflow.comP10 Led Matrix 64x32 not showing true in pixeltime (PxMatrix library) with ESP8266 NodeMCUelectronics.stackexchange.comDriving a raw Dot-Matrix LC Displaygithub.commrcodetastic/ESP32-HUB75-MatrixPanel-DMA (GitHub README)

This guide summarises the public sources listed above in our own words. Check the original documentation before relying on exact figures.