I am trying to serial print the value of b[0][0].

Has to be zero but it dose not work!

Here is the code

void setup() {
  byte b[321][241];

void loop() {


If the array is small like b[2][2] it dose work

In theory esp32 has ram of ‎520 KiB SRAM so can this be a problem?

Here is the error code

rst:0x8 (TG1WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
mode:DIO, clock div:1
ho 0 tail 12 room 4
ho 0 tail 12 room 4
entry 0x400806b8

The code complies fine but the error gets when esp32 is running

esp32 version for arduino is 1.0.4

  • what about b[2][241] or b[321][2] ? – jsotola Jun 8 '20 at 8:00
  • Stack size is usually much smaller than RAM, especially if it's running under RTOS, so I'd expect problems with it. – KIIV Jun 8 '20 at 8:05
  • @jsotola for b[321][2] I get the value 165 as output shouldn't it be zero also for b[2][241] is 165 – Avon97 Jun 8 '20 at 9:48

The ESP32 uses FreeRTOS to run everything, and that includes the Arduino API. Your code is running in a thread of its own ("loopTask"), and that task by default has 8192 bytes of stack allocated to it.

xTaskCreateUniversal(loopTask, "loopTask", 8192, NULL, 1, &loopTaskHandle, CONFIG_ARDUINO_RUNNING_CORE);

You cannot create local variables and other stack data that totals more than 8192 bytes.

Instead you will either have to have the variable as a global variable (or static local) so it gets allocated in the global data segment, or use new or malloc to create it on the heap (and don't forget the corresponding delete or free call when you're done with it).

  • creating the variable as global seems to solve the problem. – Avon97 Jun 8 '20 at 10:16

This may be due to serial buffer size. ESP32 may wrire new data before finshing previous transfer. Add a delay after print line and see.

  • nop that did not work – Avon97 Jun 8 '20 at 7:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.