VS1053 SD no audio on ESP32-S3

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
kieres
 
Posts: 8
Joined: Sun Feb 02, 2014 6:32 am

VS1053 SD no audio on ESP32-S3

Post by kieres »

I have the VS1053 breakout running on ESP32-DevkitC-1 using Arduino IDE 2.x. When running the "player_simple.ino" example (after setting my pins), I get:
VS1053 found
and a file list of the SD card, and then:
Playing track 001
Playing track 002
Done playing music
But there is no sound. There are seconds passed during playing, but not the full time of the mp3 files.
I am able to get the VS1053 to stream internet radio, with no SD card, and that (mostly) works and has sound.
The SD card has the appropriate mp3 files at a 128k bitrate. I have tested it through many iterations of the ESP32 SD_Test example.
Here is the code:

Code: Select all

/*************************************************** 
  This is an example for the Adafruit VS1053 Codec Breakout

  Designed specifically to work with the Adafruit VS1053 Codec Breakout 
  ----> https://www.adafruit.com/products/1381

  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution
 ****************************************************/
#include <SPI.h>
#include <Adafruit_VS1053.h>
#include <SD.h>
#define VS_CS   4     // chip select (other spi is defined in the screen spi)
#define VS_DCS  5     // dcs
#define VS_RST  6     // reset
#define SD_CS   21     // SD chip select was 7
                      // DREQ should be an interrupt pin, see http://arduino.cc/en/Reference/attachInterrupt
#define VS_DREQ 15 // VS1053 Data request, all ESP32 GPIO pins are interrupt-capable pins
#define VS_SCLK 16
#define VS_MOSI 17
#define VS_MISO 18
SPIClass SPI2(0);
Adafruit_VS1053_FilePlayer musicPlayer = 
  // create breakout-example object!
  Adafruit_VS1053_FilePlayer(VS_MOSI, VS_MISO, VS_SCLK, VS_RST, VS_CS, VS_DCS, VS_DREQ, SD_CS);
 void setup() {
  Serial.begin(9600);
  Serial.println("Adafruit VS1053 Simple Test");

  if (! musicPlayer.begin()) { // initialise the music player
     Serial.println(F("Couldn't find VS1053, do you have the right pins defined?"));
     while (1);
  }
  Serial.println(F("VS1053 found"));
  
   SPI2.begin(VS_SCLK, VS_MISO, VS_MOSI, SD_CS);
   
   if (!SD.begin(SD_CS, SPI2)) {
    Serial.println(F("SD failed, or not present"));
    while (1);  // don't do anything more
  }

  // list files
  printDirectory(SD.open("/"), 0);
  
  // Set volume for left, right channels. lower numbers == louder volume!
  musicPlayer.setVolume(20,20);

  // Timer interrupts are not suggested, better to use DREQ interrupt!
  //musicPlayer.useInterrupt(VS1053_FILEPLAYER_TIMER0_INT); // timer int

  // If DREQ is on an interrupt pin (on uno, #2 or #3) we can do background
  // audio playing
  musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT);  // DREQ int
  
  // Play one file, don't return until complete
  Serial.println(F("Playing track 001"));
  musicPlayer.playFullFile("/track001.mp3");
  // Play another file in the background, REQUIRES interrupts!
  Serial.println(F("Playing track 002"));
  musicPlayer.startPlayingFile("/track002.mp3");
}

void loop() {
  // File is playing in the background
  if (musicPlayer.stopped()) {
    Serial.println("Done playing music");
    while (1) {
      delay(10);  // we're done! do nothing...
    }
  }
}
I can't use the default SPI because I have a screen attached to the hardware SPI pins and it needs to update quickly.

Anyone have any ideas as to what the problem is? Thanks

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: VS1053 SD no audio on ESP32-S3

Post by mikeysklar »

You have interrupts enabled and that has been a source of problems with the ESP32s. Have you tried turning them off? Comment out this line:

Code: Select all

 musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT);  // DREQ int
More in this github thread.

User avatar
kieres
 
Posts: 8
Joined: Sun Feb 02, 2014 6:32 am

Re: VS1053 SD no audio on ESP32-S3

Post by kieres »

mikeysklar wrote: Sat May 20, 2023 6:04 pm You have interrupts enabled and that has been a source of problems with the ESP32s. Have you tried turning them off? Comment out this line:

Code: Select all

 musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT);  // DREQ int
More in this github thread.
I commented out the line but the result is the same.

Code: Select all

Adafruit VS1053 Simple Test
VS1053 found
System Volume Information/
	IndexerVolumeGuid		76
02_-_Vegetable_Medley.mp3		10821632
04 - Why does the sun shine.mp3		2192748
01-The Verbrilli Sound - Sunrise At Atlantis.mp3		3532677
sd/
	AJNC.mp3		4087936
track001.mp3		3532677
track1.ogg		13370619
track002.mp3		5230592
Playing track 001
Playing track 002
Done playing music

User avatar
kieres
 
Posts: 8
Joined: Sun Feb 02, 2014 6:32 am

Re: VS1053 SD no audio on ESP32-S3

Post by kieres »

I have now moved the pins to the default SPI so I could eliminate SPI2, if that was the issue, but still having the same problem.

Code: Select all

...
#define VS_CS   8     // chip select (other spi is defined in the screen spi)
#define VS_DCS  3     // dcs
#define VS_RST  6     // reset
#define SD_CS   21     // SD chip select was 7
                      // DREQ should be an interrupt pin, see http://arduino.cc/en/Reference/attachInterrupt
#define VS_DREQ 15 // VS1053 Data request, all ESP32 GPIO pins are interrupt-capable pins
#define VS_SCLK 12
#define VS_MOSI 11
#define VS_MISO 13
...
 // musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT);  // DREQ int

User avatar
kieres
 
Posts: 8
Joined: Sun Feb 02, 2014 6:32 am

Re: VS1053 SD no audio on ESP32-S3

Post by kieres »

Sorry about all the follow-ups...
OK, so I've narrowed it down to the use of:

Code: Select all

...
SPIClass SPI2(0);
...
SPI2.begin(VS_SCLK, VS_MISO, VS_MOSI, SD_CS);
if (!SD.begin(SD_CS, SPI2)) {
It seems that after initializing SPI2 with the same pins as Adafruit_VS1053_FilePlayer, the VS1053 no longer outputs audio. It plays nothing on sineTest (but still delays for the interval).
I'm now thinking there's a problem with the Software SPI mode not using the SD card correctly, and SPI2.begin shouldn't have to be used.
I've been looking at the library source, but I haven't found anything yet.

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”