baldram/ESP_VS1053_Library

Not able to run the lib with ESP32 Wrover

rjrajbir opened this issue · 1 comments

Hi I have made my custom hardware where I am custom SPI pins to communicate with VS1053b chip and A TFT Display.

I am able to test my display properly but not able to run VS1053b.
I checked with logic analyser that I am not able to get the proper SPI communication with VS1053b and esp32 wrover.

Here is my code


  The circuit (example wiring for ESP8266 based board like eg. LoLin NodeMCU V3):
  --------------------------------
  | VS1053  | ESP8266 |  ESP32   |
  --------------------------------
  |   SCK   |   D5    |   IO18   |
  |   MISO  |   D6    |   IO19   |
  |   MOSI  |   D7    |   IO23   |
  |   XRST  |   RST   |   EN     |
  |   CS    |   D1    |   IO5    |
  |   DCS   |   D0    |   IO16   |
  |   DREQ  |   D3    |   IO4    |
  |   5V    |   5V    |   5V     |
  |   GND   |   GND   |   GND    |
  --------------------------------

  Note: It's just an example, you may use a different pins definition.
  For ESP32 example, please follow the link:
    https://github.com/baldram/ESP_VS1053_Library/issues/1#issuecomment-313907348

*/

// This ESP_VS1053_Library
#include <VS1053.h>

// Please find SampleMp3.h file here:
//   github.com/baldram/ESP_VS1053_Library/blob/master/examples/Mp3PlayerDemo/SampleMp3.h
#include "SampleMp3.h"

#define SCK 14
#define MISO 12
#define MOSI 13
#define XRST 32

//#ifdef ARDUINO_ARCH_ESP32
#define VS1053_CS    27
#define VS1053_DCS    5
#define VS1053_DREQ   2
//#endif

#define VOLUME  100 // volume level 0-100

VS1053 player(VS1053_CS, VS1053_DCS, VS1053_DREQ);

void setup() {
  Serial.begin(115200);

  // initialize SPI
  SPI.begin();

  Serial.println("Hello VS1053!\n");
  // initialize a player
  player.begin();
  Serial.println("Code is here before chip");

  while (player.isChipConnected() == 0)
  {
    Serial.println("No Chip Detected!");
  }

  if (player.getChipVersion() == 4) { // Only perform an update if we really are using a VS1053, not. eg. VS1003
    player.loadDefaultVs1053Patches();
    Serial.println("Code is here 1");
  }
  player.switchToMp3Mode(); // optional, some boards require this
  player.setVolume(VOLUME);
  //Serial.println("Code is here");
}

void loop() {
  Serial.println("Playing sound... ");

  // play mp3 flow each 3s
  player.playChunk(sampleMp3, sizeof(sampleMp3));
  delay(3000);
}```


I am confused about these pin decelartions
#define SCK 14
#define MISO 12
#define MOSI 13
#define XRST 32

Please help

You gotta search for ESP32 examples for usage of both SPI controllers, VSPI and HSPI.

This could look something like:

#include <WiFi.h>
#define VS1053_CS     32
#define VS1053_DCS    33
#define VS1053_DREQ   35


// zweiter SPI Kanal: HSPI
SPIClass SPI2(HSPI);

// TFT ESP32  
  #define TFT_CS        15 // 5 -15 CS
  #define TFT_RST       16 // Reset
  #define TFT_DC        17 // A0

// For 1.44" and 1.8" TFT with ST7735 use:
Adafruit_ST7735 tft = Adafruit_ST7735(&SPI2, TFT_CS, TFT_DC, TFT_RST);