ESP32 continuously rebooting when using Adafruit Neo_Matrix and Adafruit_Neopixel with WS2812 RGBLED 8x32 matrix

Hi,
I'm trying to display a short text message ("Ornella bella") on a WS2812B RGBLED 8x32 matrix but - as a newbie as I am - I'm encountering many difficulties.
My setup uses a separate 5V power source for the LED matrix and an ESP32 to run the code. The problem is that, if I use FastLED it seems to work fine and I succeded in controlling the LEDs for some light effects but I was not able to find a simple example to display text with this library.
If, on the contrary, I try to use the Adafruit Neo-Matrix and Adafruit_Neopixel libraries ( that are used in some tutorials on the web to scroll text messages on the RGB LED matrix) my ESP32 is continuously rebooting without any LED working.
I found a discussion on this forum on this matter and the solution was found by the same forumer that had raised the issue
(Adafruit Neomatrix ESP WROOM 32 reboots - #9 by tjones99):

However, I'm already using an updated Arduino IDE version (2.3.2) and also the Adafruit libraries are updated.
This is the code I'm trying to use (adapted from an example shown in a tutorial on the web, just changed the content of the message)

#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>

#define PIN 26  ////ESP32 pin for data

Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(32, 8, PIN,
  NEO_MATRIX_TOP    + NEO_MATRIX_LEFT +
  NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG,
  NEO_GRB            + NEO_KHZ800);

const uint16_t colors[] = {
  matrix.Color(204, 0, 204), matrix.Color(204, 204, 0), matrix.Color(0, 255, 255),
  matrix.Color(255, 10, 127), matrix.Color(127, 0, 255), matrix.Color(0, 255, 0),
  matrix.Color(255, 99, 255)};

void setup() {
  matrix.begin();
  matrix.setTextWrap(false);
  matrix.setBrightness(40);
  matrix.setTextColor(colors[0]);
}

int x = matrix.width();
int pass = 0;

void loop() {
  matrix.fillScreen(0);    //Turn off all the LEDs
  matrix.setCursor(x, 0);
  matrix.print(F("Ornella bella"));

  if( --x < -110 ) {
    x = matrix.width();

    if(++pass >= 8) pass = 0;
    matrix.setTextColor(colors[pass]);
  }
  matrix.show();
  delay(33);
}

Thanks really for your help

Could this be a power supply problem?

Did your FastLED code have a command to automatically limit the power drawn by the matrix? I don't know if the Adafruit library has a similar function to that, but you could try reducing the brightness to see if that prevents the restarts.

With a 32x8 matrix, the maximum current draw could be as high as 15A at maximum brightness. Even with .setBrightness(40) it could be 2.5A

Hi,
thanks for your prompt suggestion.
I tried to lower the brightness to 20 with the command matrix.setBrightness(20) in the setup but the problem persists and even lowering brightness to 10 doesn't solve the issue.
However, I've already ordered a week ago a 5V powersource capable to deliver 20A and I'll try this.
If also this setup fails I'll ask again for help.
Two more maybe silly questions from a newbie

  1. Why "sometimes" when I connect my ESP32 to the USB port of PC all the leds turn on and the same happens when I turn on the external powersource. Why this erratic behaviour ? My ESP32 is connected from 5v pin to the 5v pin of the matrix and from the GND to the GND of the matrix, with data pin 26; then the matrix is also powered from the external source (5V to 5V and GND to GND with the central connection of the matrix), The GNDs are connected

  2. Why the ESP32 is powered also from the external source when I detach the connection to the USB port. I thought that the two power sources were independent. Thanks again

When the ESP is powered up, for a second or less, all the pins default to INPUT and are floating. After that, setup() runs and pin 26 that drives the matrix it set to OUTPUT. But while pin 26 is floating, the matrix can pick up random noise from the environment and interpret that as data, switching LEDs on when it is not intended. Try connecting a 10K pulldown to pin 26.

Are you using a level shifter to up the logic level from the 3.3v that the ESP32 puts out to the 5v logic level that the WS2812's need ?

const uint16_t colors[] = {
  matrix.Color(204, 0, 204),

I am not familiar with the matric library but does it use 16-bit colors ?
Ah it's using Adafruit_GFX hmm.. then i guess it might.

ah you are reading beyond the size of the array

const uint16_t colors[] = {
  matrix.Color(204, 0, 204), matrix.Color(204, 204, 0), matrix.Color(0, 255, 255),
  matrix.Color(255, 10, 127), matrix.Color(127, 0, 255), matrix.Color(0, 255, 0),
  matrix.Color(255, 99, 255)};

those are only 7 different colors and

    if(++pass >= 8) pass = 0;
    matrix.setTextColor(colors[pass]);

that will allow

matrix.setTextColor(colors[7]);

which does not exists and should result in unexpected behavior to say the least.

You are powering esp32 contemporarily from usb and from 5V pin(Vin). If your intention is not to power Esp from led power supply, remove that 5V wire between matrix and Esp.

Hi, thanks for your explanation.
I'd decided to connect 5V of ESP32 with the 5V of the RGBLED matrix and GND to GND and DIN with pin 26 ( besides the connection with a power source to the "central" connection of the matrix) because I'd found this arrangement in a tutorial on a web.
However I disconnected the 5V of ESP32 but still when I try to run an example code wirh Adafruit Neo_Matrix and Adafruit Neo_Pixel the ESP32 keeps on rebooting.

Hi, thx for the suggestion.
I connected a 10K resistor between datapin of the ESP32 and GND and seems to work. Have a nice day

1 Like

Hi, thx for the time you spent controlling the code. but due to my very limited knowledge level of programming, my answers to your questions/remarks could be wrong or not pertinent (I apologize in advance)
Your first question

Are you using a level shifter to up the logic level from the 3.3v that the ESP32 puts out to the 5v logic level that the WS2812's need ?

I'm connecting the 5V of the ESP32 to the 5Vpin of the matrix so I don't think that I would need a level shifter from 3.3v (not sure of this)

Your observation

is, due to my ignorance, obscure. I got the code with the mistake you found from an example that in the video was working.
However, I've tried also with trhis simpler code, with just one color that is adapted again from a code found in a tutorial (just changed the text message) but still I keep on getting the same rebooting of the ESP32.

#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>

#define PIN 5

Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(32, 8, 5,
  NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
  NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG,
  NEO_GRB + NEO_KHZ800);

void setup() {
  matrix.begin();
  matrix.setTextWrap(false);
  matrix.setBrightness(40);
  matrix.setTextColor(matrix.Color(255, 0, 0)); // Red color
}

int x = matrix.width();

void loop() {
  matrix.fillScreen(0);
  matrix.setCursor(x, 0);
  matrix.print(F("Ornella bella"));
  if (--x < -36) {
    x = matrix.width();
  }
  matrix.show();
  delay(100);
}

Reading the WS2812 datasheet will probably clarify that you do, in theory. In practice however there is a chance you get away without one, though i always use a 74HCT04 (twice through two of the gates) to ensure 5v logic levels which does work quite a bit better.

these things happen

Well then the issue is not related. As stated before i never use the libraries you do. I use Makuna Neopixelbus It does come with a great matrix function i think, but i have never tried it.

Hi,
I understand from your post that you're a looooong way above me but this is quite understandable since I'm old (74) and I'm a newbie (just one year since I entered as a naive amateur the microcontroller/microprocessor world coming from ear/skull base surgery).
And this is why I appreciate so much the time you're spending to help me.
I've tried to look at Makuna Neopixelbus library but again I was not able to find any example dealing with displaying text on a WS28212b RGBLED 8x32 matrix.
Do you have any referenceworking with ESP32 that could be useful for me , excluding Adafruit Neo_Matrix and Neo_pixel libraries that cause the continuous rebooting of my ESP32 ?
FastLED seems to work with my hardware setup but I was not able to find any simple example to display a text message.
Thanks

I have no idea how above you am and quite frankly i don't care.

On this particular subject i have some information and ideas, but mainly, i am not sure what is causing your issue with the matrix library. I have some understanding of the Adafruit_GFX.h library, and basically it is quite possible to use it also while using another library to generate the actual signal.

Me neither. I was quite surprised, since in the arduino reference it mentions those. As said, i've never needed it.

Also as said before i don't know why the code you are using is causing issues. Have you tried a simple sketch using just Adafruit_NeoPixel.h and see if that works ? basically your matrix is a 8x32 = 256 pixel board.

Tackling this issue is doing it by matter of exclusion.

The Array wasn't the problem, is the matrix library at fault ?

Mind you, we may have missed it somehow. You could start a conversation about it. The author will probably enlighten you on the matter. Either it's there or it's not.

Thanks for the advice. I'll try to contact the Author. Have a nice day

Which version of the ESP32 board package are you using. Maybe After upgrading to ESP32 package 3.0.0, Neopixel crashes with >75 pixels can shine some light on your problem.

Hi, really thanks for the very interesting link and for your attention to my needs.
You were quite right.
Indeed I resolved my issue by downgrading the ESP32 package from 3.0.1 to 2.0.17 and I was able to have the text message scrolling along the WS2812b RGBLED 32x8 matrix I was using, after a couple of days trying to find a mistake in my code/arrangement that as a newbie I thought i've made.

I always have endless hassles with ESP based boards; I hate working with them because of changes in the board package that breaks working stuff.

I never update cores or libraries without a good reason.

If you want to play it safe, use a portable install of IDE 1.8.19 for your project. You will always have the complete "package" (IDE, cores, libraries) that you used for that project so even in a years time you can still compile with exactly the same versions of everything.

Hi, your suggestion is quite logic and can save a lot of time struggling with unwanted and unknown changes of a package that is "updated" ( but alas too often not "upgraded") responsible for awkward behaviour or crash of a functioning code.
Certainly I follow your suggestion
Thx again.
Have a nice day.