Error when Audio.h added to sketch

Please post the full and exact text of the error message.

Sketch uses 1557749 bytes (118%) of program storage space. Maximum is 1310720 bytes.
Global variables use 61316 bytes (18%) of dynamic memory, leaving 266364 bytes for local variables. Maximum is 327680 bytes.
Sketch too big; see https://support.arduino.cc/hc/en-us/articles/360013825179 for tips on reducing it.
text section exceeds available space in board

Compilation error: text section exceeds available space in board

What partition scheme have you selected?
Do you need OTA program changes?

I'm sorry but I have no idea what you are asking. If OTA means over the air then none needed. It's a project that once it's done it will stay like that. Maybe change colors here or there within the code but that will be done via usb.


```cpp
#include "Arduino.h"

#include "WiFi.h"

#include "Audio.h"

#define I2S_DOUT 25

#define I2S_BCLK 27

#define I2S_LRC 26

Audio audio;

String ssid = "xxxx";

String password = "xxxxxxxxxx";

void setup() {

  WiFi.disconnect();

  WiFi.mode(WIFI_STA);

  WiFi.begin(ssid.c_str(), password.c_str());

  while (WiFi.status() != WL_CONNECTED)

    delay(1500);

  audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);

  audio.setVolume(30);

  audio.connecttohost("http://rfcm.streamguys1.com/christianhitssk-mp3");
}

void loop()

{

  audio.loop();
}

I tried this simple wifi radio that was one of the first projects I tried to verify sound. This also gives error of too much memory. If these libraries get so large that you can't add any actual code then what are we to do?

Sketch uses 1408916 bytes (107%) of program storage space. Maximum is 1310720 bytes.
Sketch too big; see https://support.arduino.cc/hc/en-us/articles/360013825179 for tips on reducing it.
Global variables use 63516 bytes (19%) of dynamic memory, leaving 264164 bytes for local variables. Maximum is 327680 bytes.
text section exceeds available space in board

Compilation error: text section exceeds available space in board

In the IDE under Tools, change the memory partition scheme to something that will accommodate your program.

Try the one for Huge APP.

Sketch uses 1492452 bytes (47%) of program storage space. Maximum is 3145728 bytes.
Global variables use 64976 bytes (19%) of dynamic memory, leaving 262704 bytes for local variables. Maximum is 327680 bytes.

That worked. At least it compiled. So the partition scheme changes the way the board uses the available memory.

Ok, I got it to compile but, I get no sound. No errors compiling. However, looking at the serial monitor I get some kind of error and reboots. Playing mp3 from sd works great separately. when combined I get that error with reboot. I will attach the code and then the serial output. Notice when the code goes through the pink matched card I get no error because I didn't call for sound.


```cpp
#include "Adafruit_NeoPixel.h"
#include "Audio.h"
#include "SD.h"
#include "FS.h"
#include "Arduino.h"
#include <MFRC522v2.h>
#include <MFRC522DriverSPI.h>
#include <MFRC522DriverPinSimple.h>
#include <MFRC522Debug.h>

MFRC522DriverPinSimple ss_pin(5);   // Configurable, see typical pin layout above.
MFRC522DriverSPI driver{ ss_pin };  // Create SPI driver.
MFRC522 mfrc522{ driver };          // Create MFRC522 instance.

#define PIN 12
#define PIN2 13
#define I2S_DOUT 25
#define I2S_BCLK 27
#define I2S_LRC 26
#define RST_PIN 15
#define SPI_MOSI 23  // SD Card
#define SPI_MISO 19
#define SPI_SCK 18
#define SD_CS 17

Audio audio;

Adafruit_NeoPixel strip = Adafruit_NeoPixel(12, PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip2 = Adafruit_NeoPixel(12, PIN2, NEO_GRB + NEO_KHZ800);



void setup() {
  Serial.begin(115200);  // Initialize serial communications with the PC for debugging.
  while (!Serial)
    ;                                                      // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4).
  mfrc522.PCD_Init();                                      // Init MFRC522 board.
  MFRC522Debug::PCD_DumpVersionToSerial(mfrc522, Serial);  // Show details of PCD - MFRC522 Card Reader details.
  Serial.println(F("Scan PICC to see UID"));
  // LED
  strip.begin();
  strip2.begin();
  strip.setBrightness(15);
  strip2.setBrightness(15);
  strip.show();   // Initialize all pixels to 'off'
  strip2.show();  // Initialize all pixels to 'off'

  //Audio
  pinMode(SD_CS, OUTPUT);
  digitalWrite(SD_CS, HIGH);
  SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
  //SPI.setFrequency(1000000);
  if (!SD.begin(SD_CS)) {
    Serial.println("Error accessing microSD card!");
    while (true)
      ;
  }
  audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
}

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}

void colorWipe2(uint32_t c, uint8_t wait) {
  for (int i = strip2.numPixels(); i >= 0; i--) {
    strip2.setPixelColor(i, c);
    strip2.show();
    delay(wait);
  }
}

void loop() {
  audio.loop();

  if (!mfrc522.PICC_IsNewCardPresent() || !mfrc522.PICC_ReadCardSerial()) {
    return;
  }

  // Dump debug info about the card; PICC_HaltA() is automatically called.
  Serial.print("Card UID: ");
  MFRC522Debug::PrintUID(Serial, (mfrc522.uid));
  Serial.println();


  String uidString = "";
  for (byte i = 0; i < mfrc522.uid.size; i++) {
    if (mfrc522.uid.uidByte[i] < 0x10) {
      uidString += "0";
    }
    uidString += String(mfrc522.uid.uidByte[i], HEX);
  }
  Serial.println(uidString);
  if (uidString == "93abe51a") {

    Serial.println(F("Access Granted Pink"));
    colorWipe(strip.Color(0, 255, 0), 60), colorWipe2(strip2.Color(0, 255, 0), 60);
    colorWipe(strip.Color(0, 0, 0), 1), colorWipe2(strip2.Color(0, 0, 0), 1);
    //audio.setVolume(21);
    //audio.connecttoFS(SD, "/Foolish.wav");

  } else if (uidString == "187a3999") {

    Serial.println(F("Access Granted Grey"));
    colorWipe(strip.Color(0, 0, 255), 60), colorWipe2(strip2.Color(0, 0, 255), 60);
    colorWipe(strip.Color(0, 0, 0), 1), colorWipe2(strip2.Color(0, 0, 0), 1);
    audio.setVolume(21);
    audio.connecttoFS(SD, "/VaderWaiting.wav");

  } else {

    Serial.println(F("Access Denied"));
    colorWipe(strip.Color(255, 0, 0), 60), colorWipe2(strip2.Color(255, 0, 0), 60);
    colorWipe(strip.Color(0, 0, 0), 1), colorWipe2(strip2.Color(0, 0, 0), 1);
    audio.setVolume(21);
    audio.connecttoFS(SD, "/comeback.wav");
  }
}

Card UID:  18 7A 39 99
187a3999
Access Granted Grey
assert failed: xQueueSemaphoreTake queue.c:1657 (pxQueue->uxItemSize == 0)
Backtrace: 0x400833ad:0x3ffb1ef0 0x4008e50d:0x3ffb1f10 0x40093fe2:0x3ffb1f30 0x4008ed06:0x3ffb2060 0x4008ee20:0x3ffb20a0 0x40085157:0x3ffb20c0 0x40085249:0x3ffb2100 0x400852e2:0x3ffb2120 0x401a012e:0x3ffb2150 0x401a01f9:0x3ffb2190 0x4010278b:0x3ffb21b0 0x401023f3:0x3ffb21d0 0x400dcac1:0x3ffb21f0 0x400e08eb:0x3ffb2220 0x400d2bbe:0x3ffb2240 0x401099f8:0x3ffb2290
ELF file SHA256: c8974b2f8682991a
Rebooting...
ets Jul 29 2019 12:21:46
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1448
load:0x40078000,len:14844
ho 0 tail 12 room 4
load:0x40080400,len:4
load:0x40080404,len:3356
entry 0x4008059c
Firmware Version: 0x92 = v2.0

Scan PICC to see UID
Card UID:  93 AB E5 1A
93abe51a
Access Granted Pink


Card UID:  78 E2 AF 99
78e2af99
Access Denied
assert failed: xQueueSemaphoreTake queue.c:1657 (pxQueue->uxItemSize == 0)
Backtrace: 0x400833ad:0x3ffb1ef0 0x4008e50d:0x3ffb1f10 0x40093fe2:0x3ffb1f30 0x4008ed06:0x3ffb2060 0x4008ee20:0x3ffb20a0 0x40085157:0x3ffb20c0 0x40085249:0x3ffb2100 0x400852e2:0x3ffb2120 0x401a012e:0x3ffb2150 0x401a01f9:0x3ffb2190 0x4010278b:0x3ffb21b0 0x401023f3:0x3ffb21d0 0x400dcac1:0x3ffb21f0 0x400e08eb:0x3ffb2220 0x400d2bbe:0x3ffb2240 0x401099f8:0x3ffb2290
ELF file SHA256: c8974b2f8682991a
Rebooting...
ets Jul 29 2019 12:21:46
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1448
load:0x40078000,len:14844
ho 0 tail 12 room 4
load:0x40080400,len:4
load:0x40080404,len:3356
entry 0x4008059c
Firmware Version: 0x92 = v2.0
Scan PICC to see UID

I have no idea what is going on, but you might get a clue from using the EspExceptionDecoder to analyse the Backtrace.

https://github.com/me-no-dev/EspExceptionDecoder?tab=readme-ov-file

I do not think that the ExceptionDecoder tools works in IDE 2.x.x and you will need to install 1.8.19 to compile and run the sketch to get the error and feed it to the decoder.

Playing mp3 from sd works great separately. when combined I get that error with reboot.

Combined with what?

I'm not very familiar with the esp32 and what you have going on with the audio files. I would suggest that you create a more simple environment perhaps without the NeoPixel and the card reader to see what is going on when you call for sound.

That’s what I meant by separately. I ran a simple play from sd code and it works great. I also ran the code with rfid and neopoxels and it run great. When I combine the sound with the rfid and neopoxels I get that error on the serial output. If you can look at the error I posted you could see that the first and the last get the error but the one in the middle “pink” does not. That is because I did not include the call for sound in that “if” code.
The weird thing is I have a working model from last year that I had not compiled for awhile. When I tried to compile to duplicate is when I started getting all these errors. I have completely erased all arduino files including in local data file and re-installed the older IDE and libraries but still get the compiling error and the memory error we solved earlier. Although I never had that memory problem before. IDK. It’s hard to learn something when they change so fast, especially as a hobby.

Heck, on the original I even have it triggering a different relay and combination of both relays.

Wow, great surprise this afternoon. I just upgraded everything including to the new IDE just released, and everything works! the only issue I had was the memory thig which cattledog had already helped me with. Thanks alot for evreyones help.

1 Like

It is true that one is specific to Arduino IDE 1.x. However, there is a new one for Arduino IDE 2.x: