Error in running code. E (2244)

Obviously I'm a noob and am trying to build the sketch little by little by cut and paste. Using ESP32 Dev board on Arduino IDE 2.3.2, RFID-RC522, MAX98357A AMP, two led circles (12 led each) on separate pins and a dual relay module. I have so far had success with all parts separately. I also have success with all parts together except the sound amp.
I scan the rfid1 and access is denied the two circles light up red no relays activated. I scan the rfid2 and access is granted one circle lights up green and one relay activated for certain time. I scan rfid3 access is granted the other circle lights up green and the other relay is activated for certain time. Serial shows the appropriate messages for each scenario. The problem comes when I try to do audio in combination with the rest. The code does not give me an error but when running I get no sound and see:
"E (2244) I2S:register I2S object to platform failed
00M in SBR, can't allocate 50788 bytes"

Any help would be appreciated.

You might want to look at this How to get the best out of this forum before you proceed any further.

It will tell you how to post code on this forum. It will also inform you that to get any practical help we need to see the schematic of your circuit. Nothing fancy just use a pence and paper, and photograph it. But try and get the aspect ratio right. Don't post it in prorate mode when you have drawn it in landscape mode.

/*
 * For more detail (instruction and wiring diagram), visit https://esp32io.com/tutorials/esp32-rfid-nfc-door-lock-system
 */

#include <SPI.h>
#include <MFRC522.h>
#include <Adafruit_NeoPixel.h>
#include "AudioGeneratorAAC.h"
#include "AudioOutputI2S.h"
#include "AudioFileSourcePROGMEM.h"
#include "foolishaac.h"

#define SS_PIN    5  // ESP32 pin GPIO5
#define RST_PIN   15 // ESP32 pin GPIO15
#define RELAY_PIN1 32 // ESP32 pin GPIO32 connects to relay1
#define RELAY_PIN2 33 // ESP32 pin GPIO33 connects to relay2
#define PIN_WS2812B1 13  // The ESP32 pin GPIO13 connected to WS2812B
#define NUM_PIXELS1 12   // The number of LEDs (pixels) on WS2812B LED strip
#define PIN_WS2812B2 12  // The ESP32 pin GPIO12 connected to WS2812B
#define NUM_PIXELS2 12   // The number of LEDs (pixels) on WS2812B LED strip

Adafruit_NeoPixel strip1 = Adafruit_NeoPixel(NUM_PIXELS1, PIN_WS2812B1, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip2 = Adafruit_NeoPixel(NUM_PIXELS2, PIN_WS2812B2, NEO_GRB + NEO_KHZ800);
AudioFileSourcePROGMEM *in;

AudioGeneratorAAC *aac;
AudioOutputI2S *out;

MFRC522 rfid(SS_PIN, RST_PIN);

byte keyTagUID1[7] = {0x05, 0x2C, 0x7A, 0xD2, 0xC2, 0x42, 0x84};
byte keyTagUID2[7] = {0x02, 0x20, 0x38, 0xAC, 0x4B, 0x54, 0x87};
byte keyTagUID3[7] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
byte keyTagUID4[7] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
byte keyTagUID5[7] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
byte keyTagUID6[7] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};


void setup() {
  Serial.begin(115200);
  SPI.begin(); // init SPI bus
  rfid.PCD_Init(); // init MFRC522
  pinMode(RELAY_PIN1, OUTPUT); // initialize pin as an output.
  digitalWrite(RELAY_PIN1, HIGH); // lock the door
  pinMode(RELAY_PIN2, OUTPUT); // initialize pin as an output.
  digitalWrite(RELAY_PIN2, HIGH); // lock the door
  Serial.println("Tap an RFID/NFC tag on the RFID-RC522 reader");
  strip1.begin();  // initialize WS2812B strip object (REQUIRED)
  strip1.setBrightness(30); // a value from 0 to 255
  strip2.begin();  // initialize WS2812B strip object (REQUIRED)
  strip2.setBrightness(30); // a value from 0 to 255
}

void loop() {

  if (rfid.PICC_IsNewCardPresent()) { // new tag is available
    if (rfid.PICC_ReadCardSerial()) { // NUID has been readed
      MFRC522::PICC_Type piccType = rfid.PICC_GetType(rfid.uid.sak);

      if (rfid.uid.uidByte[0] == keyTagUID1[0] &&
          rfid.uid.uidByte[1] == keyTagUID1[1] &&
          rfid.uid.uidByte[2] == keyTagUID1[2] &&
          rfid.uid.uidByte[3] == keyTagUID1[3] &&
          rfid.uid.uidByte[4] == keyTagUID1[4] &&
          rfid.uid.uidByte[5] == keyTagUID1[5] &&
          rfid.uid.uidByte[6] == keyTagUID1[6] ) {
        Serial.println("Access granted GREY");
        // turn on all pixels to green at the same time for two seconds
  for (int pixel = 0; pixel < NUM_PIXELS1; pixel++) {         // for each pixel
    strip1.setPixelColor(pixel, strip1.Color(0, 255, 0));  // it only takes effect if pixels.show() is called
    in = new AudioFileSourcePROGMEM(foolishaac, sizeof(foolishaac));
    aac = new AudioGeneratorAAC();
    out = new AudioOutputI2S();
    out -> SetGain(0.5);
    out -> SetPinout(27,26,25);
    aac->begin(in, out);
  }
  strip1.show();  // update to the WS2812B Led Strip
  delay(1000);     // 1 second on time

  // turn off all pixels for one seconds
  strip1.clear();
  strip1.show();  // update to the WS2812B Led Strip
  
        digitalWrite(RELAY_PIN1, LOW);  // unlock the door for 2 seconds
        delay(2000);
        digitalWrite(RELAY_PIN1, HIGH); // lock the door
      }
      else

      if (rfid.uid.uidByte[0] == keyTagUID2[0] &&
          rfid.uid.uidByte[1] == keyTagUID2[1] &&
          rfid.uid.uidByte[2] == keyTagUID2[2] &&
          rfid.uid.uidByte[3] == keyTagUID2[3] &&
          rfid.uid.uidByte[4] == keyTagUID2[4] &&
          rfid.uid.uidByte[5] == keyTagUID2[5] &&
          rfid.uid.uidByte[6] == keyTagUID2[6] ) {
        // turn on all pixels to green at the same time for two seconds
  for (int pixel = 0; pixel < NUM_PIXELS2; pixel++) {         // for each pixel
    strip2.setPixelColor(pixel, strip2.Color(0, 255, 0));  // it only takes effect if pixels.show() is called
  }
  strip2.show();  // update to the WS2812B Led Strip
  delay(1000);     // 1 second on time

  // turn off all pixels for one seconds
  strip2.clear();
  strip2.show();  // update to the WS2812B Led Strip
  
        Serial.println("Access granted PINK");
        digitalWrite(RELAY_PIN2, LOW);  // unlock the door for 2 seconds
        delay(2000);
        digitalWrite(RELAY_PIN2, HIGH); // lock the door
      }
      else
      if (rfid.uid.uidByte[0] == keyTagUID3[0] &&
          rfid.uid.uidByte[1] == keyTagUID3[1] &&
          rfid.uid.uidByte[2] == keyTagUID3[2] &&
          rfid.uid.uidByte[3] == keyTagUID3[3] &&
          rfid.uid.uidByte[4] == keyTagUID3[4] &&
          rfid.uid.uidByte[5] == keyTagUID3[5] &&
          rfid.uid.uidByte[6] == keyTagUID3[6] ) {
        Serial.println("Access granted ULY BLACK");
        // turn on all pixels to green at the same time for two seconds
  for (int pixel = 0; pixel < NUM_PIXELS1; pixel++) {         // for each pixel
    strip1.setPixelColor(pixel, strip1.Color(0, 255, 0));  // it only takes effect if pixels.show() is called
  }
  strip1.show();  // update to the WS2812B Led Strip
  delay(1000);     // 1 second on time

  // turn off all pixels for one seconds
  strip1.clear();
  strip1.show();  // update to the WS2812B Led Strip
  
        digitalWrite(RELAY_PIN1, LOW);  // unlock the door for 2 seconds
        delay(2000);
        digitalWrite(RELAY_PIN1, HIGH); // lock the door
      }
      else
      if (rfid.uid.uidByte[0] == keyTagUID4[0] &&
          rfid.uid.uidByte[1] == keyTagUID4[1] &&
          rfid.uid.uidByte[2] == keyTagUID4[2] &&
          rfid.uid.uidByte[3] == keyTagUID4[3] &&
          rfid.uid.uidByte[4] == keyTagUID4[4] &&
          rfid.uid.uidByte[5] == keyTagUID4[5] &&
          rfid.uid.uidByte[6] == keyTagUID4[6] ) {
        // turn on all pixels to green at the same time for two seconds
  for (int pixel = 0; pixel < NUM_PIXELS2; pixel++) {         // for each pixel
    strip2.setPixelColor(pixel, strip2.Color(0, 255, 0));  // it only takes effect if pixels.show() is called
  }
  strip2.show();  // update to the WS2812B Led Strip
  delay(1000);     // 1 second on time

  // turn off all pixels for one seconds
  strip2.clear();
  strip2.show();  // update to the WS2812B Led Strip
  
        Serial.println("Access granted MAGENTA");
        digitalWrite(RELAY_PIN1, LOW);  // unlock the door for 2 seconds
        delay(2000);
        digitalWrite(RELAY_PIN1, HIGH); // lock the door
      }
      else
      if (rfid.uid.uidByte[0] == keyTagUID5[0] &&
          rfid.uid.uidByte[1] == keyTagUID5[1] &&
          rfid.uid.uidByte[2] == keyTagUID5[2] &&
          rfid.uid.uidByte[3] == keyTagUID5[3] &&
          rfid.uid.uidByte[4] == keyTagUID5[4] &&
          rfid.uid.uidByte[5] == keyTagUID5[5] &&
          rfid.uid.uidByte[6] == keyTagUID5[6] ) {
        // turn on all pixels to green at the same time for two seconds
  for (int pixel = 0; pixel < NUM_PIXELS2; pixel++) {         // for each pixel
    strip2.setPixelColor(pixel, strip2.Color(0, 255, 0));  // it only takes effect if pixels.show() is called
  }
  strip2.show();  // update to the WS2812B Led Strip
  delay(1000);     // 1 second on time

  // turn off all pixels for one seconds
  strip2.clear();
  strip2.show();  // update to the WS2812B Led Strip
  
        Serial.println("Access granted BLUE");
        digitalWrite(RELAY_PIN2, LOW);  // unlock the door for 2 seconds
        delay(2000);
        digitalWrite(RELAY_PIN2, HIGH); // lock the door
      }
      else
      if (rfid.uid.uidByte[0] == keyTagUID6[0] &&
          rfid.uid.uidByte[1] == keyTagUID6[1] &&
          rfid.uid.uidByte[2] == keyTagUID6[2] &&
          rfid.uid.uidByte[3] == keyTagUID6[3] &&
          rfid.uid.uidByte[4] == keyTagUID6[4] &&
          rfid.uid.uidByte[5] == keyTagUID6[5] &&
          rfid.uid.uidByte[6] == keyTagUID6[6] ) {
        // turn on all pixels to green at the same time for two seconds
  for (int pixel = 0; pixel < NUM_PIXELS2; pixel++) {         // for each pixel
    strip2.setPixelColor(pixel, strip2.Color(0, 255, 0));  // it only takes effect if pixels.show() is called
  }
  strip2.show();  // update to the WS2812B Led Strip
  delay(1000);     // 1 second on time

  // turn off all pixels for one seconds
  strip2.clear();
  strip2.show();  // update to the WS2812B Led Strip
  
        Serial.println("Access granted PURPLE");
        digitalWrite(RELAY_PIN2, LOW);  // unlock the door for 2 seconds
        delay(2000);
        digitalWrite(RELAY_PIN2, HIGH); // lock the door
      }
      else
      {
        // turn on all pixels to red at the same time for two seconds
  for (int pixel = 0; pixel < NUM_PIXELS1; pixel++) {         // for each pixel
    strip1.setPixelColor(pixel, strip1.Color(255, 0, 0));  // it only takes effect if pixels.show() is called
  }
  for (int pixel = 0; pixel < NUM_PIXELS2; pixel++) {         // for each pixel
    strip2.setPixelColor(pixel, strip2.Color(255, 0, 0));  // it only takes effect if pixels.show() is called
  }
  strip1.show();  // update to the WS2812B Led Strip
  strip2.show();  // update to the WS2812B Led Strip
  delay(1000);     // 1 second on time

  // turn off all pixels for one seconds
  strip1.clear();
  strip1.show();  // update to the WS2812B Led Strip  
  strip2.clear();
  strip2.show();  // update to the WS2812B Led Strip
  
        Serial.print("Access denied, UID:");
        for (int i = 0; i < rfid.uid.size; i++) {
          Serial.print(rfid.uid.uidByte[i] < 0x10 ? " 0" : " ");
          Serial.print(rfid.uid.uidByte[i], HEX);
        }
        Serial.println();
      }

      rfid.PICC_HaltA(); // halt PICC
      rfid.PCD_StopCrypto1(); // stop encryption on PCD

      
    }
  }
}

What did you not understand about this comment?

:joy: sorry I had already been working on it and didn't want to discard it.

Not exactly a noob project. Programming by the copy / paste method with code that you don't understand typically leads to frustration.

It shows nothing important like the power supply and the pictures are not even labelled as to what each one is. This is is known as a physical layout diagram and is singularly useless for trying to understand a circuit.

This sort of diagram is almost universally derided on this forum.

Sorry but it takes the problem no closer to being solved.

True, trying to get my head around it. I have gotten it to do about 90% of what I intend it to. getting sound to work along with all the other is tripping me up.

Thanks, Grumpy_Mike for your willing to help. Power is being supplied from the usb since I have it connected to my computer for testing and coding. The ESP 5v pin is powering the 2 (12 Pixels each) led circles and the 2 relay module. The RFID reader and the I2S amp is powered by the 3.3v pin of the ESP32. Speaker connected to the amp output.

As far as a circuit drawing do you mean like an electrical circuit drawing of each component or just how they are connected to each other? Maye a sample drawing could help me understand. I did read the link you suggested and he shows a very detailed electrical circuit which is beyond my abilities. I also searched for other circuit diagrams and all seem like actual component circuity.

You'll likely get away with the LED strips, but trying to power a 3W audio amplifier from the ESP32's voltage regulator is simply not going to fly. It's needs a dedicated power supply.

That being said, it may not be the proximal reason for your problem. But ,it absolutely is a problem.

There's also a potential problem with the LEDs. Since they're powered by 5V, they should really be driven by 5V logic, not the ESP32's 3.3V logic. It may marginally "work", but it's not optimal. When driving such strips with 3.3V logic, I always use a level shifter. One very good one is 'AHCT125 quad buffer. You can connect it's VDD to 5V for 5V output levels while still having an input range that 3.3V logic falls well within. It's also sufficiently fast. I've used it for driving SPI LEDs at ~20MHz.

Your code doesn't attempt to play any sound, which is why you are not getting any. We need to see code that is wrong and won't work.

A circuit diagram is simply a box drawn for each component with the name of the part in the box. The boxes are connected with lines representing the wiring. Lines must be horizontal or vertical never diagonal. The connections to the part are indicated by PIN numbers, which should be placed in the box in a position to make the wiring simple. There should be no relationship between the pins on the box and the actual position there are on the physical part. Only show pin numbers that are being used.
This is three ways of showing crossing wires:-

I prefer to use type B.

This is an example of wiring up an LCD to an Arduino.

Note here the Arduino is not shown but pin numbers to it are indicated. Note also how the pin numbers on the PF8974 port expander chip are not in the same order as the physical position of the chip, but the wiring is simple. Also the use of the Ground symbol on this chip for pins 8, 1, 2 & 3. All ground symbols are connected together, the same goes for the +5V symbol. Finally yes you will have to learn the symbols for individual parts, like transistors, resistors and capacitors.

These links might help you:-
Reading a schematic

Colin's Lab video on reading a schematic

Your previous diagram had no relays on them but your code did.

The code itself is one huge loop function, this is bad. It should be broken down into functions that are called from the loop function to make it easy to understand.

The excessive use of long delays, will stop you from producing any sound anyway, unless you don't do anything else during the production of the sound.

Plus all the things that @gfvalvo said need fixing.

Understood, This is mostly for testing purposes. But I will power the LEDs and Relay board from an external 2a micro usb. There are only 12 leds per pin and running at 1/8th the power (30 out of 255). The amp has a 3.3v input and I am using a half inch speaker that is .5w at 8 ohms. The sound is literally 3 seconds long and the leds are lit for 2 seconds at a time. The sound file is stored on board.

I have it set up to read up to 6 different RFID sources although I am only using two so far. Each one with a different response and serial print. I will have to read up on how to clean it up and still function the same way. For now I could remove the other four to clean it up a bit.

I hope this is ok. If I didn't show it I will tie all the grounds together.

it is a lot lot better.
You need to add what sort of relay module you have.
The other thing I don't understand is the block that says "USB 2 Amp", what is this?
A photograph would help.

Take the code that compares each byte of the received key with the key that is recognised. Turnthis into a function where you pass in the recognised key and it returns a true or false depending on the result. Therefore you call use function for each key and in effect only write that code once.

I forgot to write it in. That is a USB 5V 2A plug. This is the relay that I am using.

Thanks for that.
But I really meant:-

I'm going to guess that it's a 5V @ 2A wall wart with a USB-A connector:

image

But he says, and shows on the diagram, that there are three outputs.