Home

Awesome

HUB75 RGB LED matrix panel library utilizing ESP32 DMA

BUILD OPTIONS | EXAMPLES | PlatformIO CI

Table of Content

Introduction

Features

ESP32 variants supported

RISC-V ESP32's (like the C3) are not supported as they do not have the hardware 'LCD mode' support.

Required memory

"What's the price for those features?" - It's memory, you pay it all by precious MCU's internal memory (SRAM) for the DMA buffer.

Please use the 'Memory Calculator' to see what is typically achievable with the typical ESP32. This is only a guide. Memory Calculator

For the ESP32-S3 only, you can use SPIRAM/PSRAM to drive the HUB75 DMA buffer when using an ESP32-S3 with OCTAL SPI-RAM (PSTRAM) (i.e. ESP32 S3 N8R8 variant). However, due to bandwidth limitations, the maximum output frequency is limited to approx. 13Mhz, which will limit the real-world number of panels that can be chained without flicker. Please do not use PSRAM as the DMA buffer if using QUAD SPI (Q-SPI), as it's too slow.

To enable PSRAM support on the ESP32-S3, refer to the build options to enable.

For all other ESP32 variants (like the most popular ‘original’ ESP32), only internal SRAM can be used, so you will be limited to the ~200KB or so of 'free' SRAM (because of the memory used for your sketch amongst other things) regardless of how many megabytes of SPIRAM/PSRAM you may have connected.

Supported panel can types

It is impossible to provide a comprehensive list of what panels are supported (or not supported) as new variations of the chips used to 'drive' these panels are created almost weekly (usually from China). You should contact the seller to confirm the chips used in a panel before purchasing to use with this library.

Ones interested in internals of such matrices could find this article useful.

Panel Scan Types

Specific chips found to work

Specific chips found NOT TO work

Please use an alternative library if you bought one of these.

Getting Started

1. Library Installation

Library also tested to work fine with PlatformIO, install into your PlatformIO projects' lib/ folder as appropriate. Or just add it into platformio.ini lib_deps section.

2. Wiring the ESP32 to an LED Matrix Panel

Refer to the '*default-pins.hpp' file within the applicable platforms folder.

If you want to change the GPIO mapping at runtime, simply provide the wanted pin mapping as part of the class initialization structure. For example, in your sketch have something like the following:

// Change these to whatever suits
#define R1_PIN 25
#define G1_PIN 26
#define B1_PIN 27
#define R2_PIN 14
#define G2_PIN 12
#define B2_PIN 13
#define A_PIN 23
#define B_PIN 19
#define C_PIN 5
#define D_PIN 17
#define E_PIN -1 // required for 1/32 scan panels, like 64x64px. Any available pin would do, i.e. IO32
#define LAT_PIN 4
#define OE_PIN 15
#define CLK_PIN 16

HUB75_I2S_CFG::i2s_pins _pins={R1_PIN, G1_PIN, B1_PIN, R2_PIN, G2_PIN, B2_PIN, A_PIN, B_PIN, C_PIN, D_PIN, E_PIN, LAT_PIN, OE_PIN, CLK_PIN};
HUB75_I2S_CFG mxconfig(
	64, // Module width
	32, // Module height
	2, // chain length
	_pins, // pin mapping
);
dma_display = new MatrixPanel_I2S_DMA(mxconfig);

Make sure you also connect one of the HUB75 interfaces ground pins to a ground pin of the ESP32, otherwise you may get electrical artefacts on LED Matrix Panel.

Various people have created PCBs for which one can simply connect an ESP32 to a PCB, and then the PCB to the HUB75 connector, such as:

Please contact or order these products from the respective authors.

How can I configure it to work with an off-the-shelf board/shield with HUB75 connector, e.g. Adafruit MatrixPortal?

You need to find the correct pin mapping for your board. For Adafruit boards/shields, you can look in one of the examples provided with the Protomatter library, for example here. Find your board variant, copy the pin values into the #defines described above, and pass the pin mapping into your mxconfig.

For example, for MatrixPortal S3, the Protomatter example file contains the following:

uint8_t rgbPins[]  = {42, 41, 40, 38, 39, 37};
uint8_t addrPins[] = {45, 36, 48, 35, 21};
uint8_t clockPin   = 2;
uint8_t latchPin   = 47;
uint8_t oePin      = 14;

which for use with this library, converts to:

#define R1_PIN 42
#define G1_PIN 41
#define B1_PIN 40
#define R2_PIN 38
#define G2_PIN 39
#define B2_PIN 37
#define A_PIN  45
#define B_PIN  36
#define C_PIN  48
#define D_PIN  35
#define E_PIN  21 
#define LAT_PIN 47
#define OE_PIN  14
#define CLK_PIN 2

HUB75_I2S_CFG::i2s_pins _pins={R1_PIN, G1_PIN, B1_PIN, R2_PIN, G2_PIN, B2_PIN, A_PIN, B_PIN, C_PIN, D_PIN, E_PIN, LAT_PIN, OE_PIN, CLK_PIN};

// Module configuration
HUB75_I2S_CFG mxconfig(
  PANEL_RES_X,   // module width
  PANEL_RES_Y,   // module height
  PANEL_CHAIN,   // Chain length
  _pins          // Pin mapping
);

Can I use with a larger panel (i.e. 64x64px square panel)?

If you want to use with a 64x64 pixel panel (typically a HUB75E panel) you MUST configure a valid E_PIN to your ESP32 and connect it to the E pin of the HUB75 panel! Hence the 'E' in 'HUB75E'

3. Run a Test Sketch

Below is a bare minimum sketch to draw a single white dot in the top left. You must call begin() before you call ANY pixel-drawing (fonts, lines, colours etc.) function of the MatrixPanel_I2S_DMA class.

Once this is working, refer to the PIO Test Patterns example. This sketch draws simple colors/lines/gradients over the entire matrix and it could help to troubleshoot various issues with ghosting, flickering, etc...

Note: Requires the use of PlatformIO, which you should probably use if you aren't already.

Further information

Can I chain panels?

Yes!

Horizontal

For example: If you want to chain two of these horizontally to make a 128x32 panel you can do so by connecting the panels in series using the HUB75 ribbon cable. Than you must provide proper configuration structure to the class constructor letting it know that you use "one long virtual matrix chain". Refer to Pattern Plasma example for all the details about configuration setup.

Finally, if you wanted to chain 4 x (64x32px) panels to make 128x64px display (essentially a 2x2 grid of 64x32 LED Matrix modules), a little more magic will be required. Refer to the VirtualMatrixPanel example and the AuroraDemo example of its practical use.

Resolutions beyond 128x64 are more likely to result in crashes due to memory constraints etc. You are on your own after this point - PLEASE do not raise issues about this, the library can't magically defeat the SRAM memory constraints of the ESP32.

ezgif com-video-to-gif

Adjusting Panel Brightness

By default you should not need to change / set the brightness value (which is 128 or 50%) as it should be sufficient for most purposes. Brightness can be changed by calling setPanelBrightness(xx) or setBrightness8(xx).

The value to pass must be a number between 0 (for a black screen) and 255 (max brightness).

Example:

void setup() {
Serial.begin(115200);
	dma_display->begin(); // setup the LED matrix
    dma_display->setBrightness8(192); //0-255
    dma_display->clearScreen();	
}

Brightness Samples

Build-time options

Although Arduino IDE does not seem to offer any way of specifying compile-time options for external libs there are other IDE's (like PlatformIO/Eclipse) that could use that. Check Build Options document for reference.

Latch blanking

If you are facing issues with image ghosting when pixels has clones with horizontal offset, than you try to change Latch blanking value. Latch blanking controls for how many clock pulses matrix output is disabled via EO signal before/after toggling LAT signal. It hides row bits transitioning and different panels may require longer times for proper operation. Default value is 1 clock before/after LAT row transition. This could be controlled with MatrixPanel_I2S_DMA::setLatBlanking(uint8_t v). v could be between 1 to 4, default is 1, larger values won't give any benefit other than reducing brightness.

An example:

dma_display->setLatBlanking(2);

Power, Power and Power!

Having a good power supply is CRITICAL, and it is highly recommended, for chains of LED Panels to have a 1000-2000uf capacitor soldered to the back of each LED Panel across the GND and VCC pins, otherwise you WILL run into issues with 'flashy' graphics whereby a large amount of LEDs are turned on and off in succession (due to current/power draw peaks and troughs).

Inspiration

This project was inspired by:

Cool uses of this library

There are a number of great looking LED graphical display projects which leverage this library, these include:

Thank you!

If you want to donate money to the project, please refer to this discussion about it. If you want to donate/buy an LED panel for the library author to improve compatibility and/or testing - please feel free to post in the same discussion.

Music

Of course, now Generative AI is everywhere. What happens when you ask AI to generate a song about an 'ESP32 HUB75 DMA LED Matrix Panel library'?

You get this.... Enjoy. 😊

It's better in real life