Go Down

Topic: PIN setup for vs1053 / ESP32 / MD_MIDIFile (Read 1 time) previous topic - next topic


Jun 12, 2019, 06:35 am Last Edit: Jun 26, 2019, 12:11 am by flossandmeditate
Newbie here so please be gentle.

I'm setting up my ESP32 WROOM32 with a VS1053 with inbuilt SDcard to run MD_MidiFile which uses SDFat.
I'll be playing MIDIFiles from the SD Card, MIDI audio playing out of the jack headphone socket on the vs1053 board and also triggering LEDs as the file plays.

What are the pin connections that i need to make between the ESP32 and VS1053?

On the VS1053 i have following pins available..
  • 5V - Easy
  • GND - Easy
  • CS
  • MISO
  • SI
  • SCK
  • XCS
  • XDCS
  • DREQ

I have been down many google dead ends so thank you in advance for your time and my apologies if this is all really obvious - i appreciate your help.

- Chris


The connections depend on how you intend to run the device. From the pins it looks like there is an SPI interface available (CS, SCK, MISO - maybe for the SD card), but the other pins are something else.

It would be useful if you look at the definition of the pins from the product spec sheet for the VS1053 board or at least provide a link to that specification.
Arduino Libraries https://github.com/MajicDesigns?tab=Repositories
Parola for Arduino https://github.com/MajicDesigns/Parola
Arduino++ blog https://arduinoplusplus.wordpress.com


Jun 25, 2019, 06:11 am Last Edit: Jun 25, 2019, 11:07 pm by flossandmeditate
Thank you for your response Marco.

I've unfortunately been unable to track down a spec sheet for the vs1053 board - https://www.aliexpress.com/i/32890307311.html

Late reply because I've been away treble checking I'm not making any obvious silly mistakes with wiring and config. Still no success - so here is what i am up to...

  • Connect Boards with...
      VS1053 - ESP32
      CS     - D22
      MISO   - D19
      SI     - D23
      SCK    - D18
      XCS    - D32
      XRESET - EN
      XDCS   - D33
      DREQ   - D35
      5V - 5v
      GND- GND
  • Plug headphones into speaker jack output from the VS1053 board
  • Load files on SD card. Confirm SD card works by successfully running SdFat examples
  • IN SdInfo.h change this value from 50 to 25, any higher gives error of 'SD init fail!'
      #define SPI_FULL_SPEED SD_SCK_MHZ(25)
  • In MD_MIDIFile_Play change SD to match CS pin
      #define  SD_SELECT  22
  • Compile to MD_MIDIFile_Play to ESP32.
  • ---RESTART ESP32---

Serial Monitor shows data flowing as I would expect eg...
2079   M T1:  Ch 1 Data C0 0
2079   M T1:  Ch 1 Data B0 7 64
2079   M T1:  Ch 1 Data B0 A 40
2080   M T1:  Ch 1 Data B0 5B 7F

Audio output through the headphones gives hisses, clicks and pops in a manner that don't quite sound random (see attached audio) and certainly don't sound like the sweet synthesized MIDI piano i was hoping for.

I tried a replacement vs1053 board just incase this one was faulty - no change.
I tried using a different pin for CS - no change

If anyone has a known working hardware setup to share then i'd love to hear about it, very happy to switch hardware. I'm chomping at the bit to build my project once these initial hardware issues are out of the way..


This might help.



Jun 25, 2019, 11:26 pm Last Edit: Jun 25, 2019, 11:34 pm by flossandmeditate
Thanks for that link - It shows the Pinout for an Arduino Uno to run the MP3Shield Library.

Unfortunately the link to the vs1053 datasheet gives a 404 not found -http://www.vlsi.fi/fileadmin/datasheets/vlsi/vs1053.pdf

I have found the full ESP32 WROOM datasheet online however - https://www.espressif.com/sites/default/files/documentation/esp32-wroom-32_datasheet_en.pdf


Jun 26, 2019, 04:37 pm Last Edit: Jun 26, 2019, 04:46 pm by Hachey
I have been looking at the VS1053 shield, starting with it attached to the UNO.
I am just trying to use ESP32 now. UNO has not enough memory to program much for this board.

I have got my program to compile for the ESP32 and loaded it up, but it is returning gobbledygook to the console as yet.

I did have to disconnect the Reset/EN between the two board when loading the code.



Plenty of info and clues
He is using this library

There seems to be two different popular libraries:-




I am working on using the SFEMP3Shield library as I wanted to use SdFat.h and it has more functionality, although is more complicated.

To compile for the ESP32 I had to make following change.

Needed to ammend as per https://github.com/SodaqMoja/Sodaq_DS3231/issues/5

Removed this from cpp file
#include <avr\pgmspace.h>

added this to header file

#if (defined(__AVR__))
#include <avr\pgmspace.h>
#include <pgmspace.h>




So the cheap ($5) VS1053 boards from aliexpress are set up for mp3/radio etc however they are not wired for handling MIDI signals despite what their item descriptions say! If you wish you can spend substantially more money and get a board that will do that from adafruit.

There is however a workaround. Mike Rainbow has beautifully documented how he hacked the board to accept MIDI input to produce audio. The mods are straightforward but require some high level soldering skills. I'm going to give it a go!



So what connections did you use and what library for the ESP32 with the VS1053 please?

I'm still struggling to get mine up and running with either the SFEMP3 or the Adafruit libraries.

I just want to play MP3s off the SDCard for the minute.

Adafruit VS1053 Simple Test Couldn't find VS1053, do you have the right pins defined?

I amended SFEMP3ShieldConfig.h to include the ESP32 pin defs

#define ESP32 1   // set to 1 if using the ESP32 with Music Shield

#elif (ESP32 == 1)
   #define MP3_XDCS    33
   #define MP3_RESET   3   //EN
//SCK   D18   Green
//MISO   D19   Yellow
   #define MP3_XCS    32   //D32
   #define MP3_DREQ    35   //D35
//MOSI   D23   Orange
   #define SD_SEL      5 //select pin for SD card usual is GPIO5

//HERE Commented out for ESP32 and using POLLED istead 

//F:\Arduino Sketches 1\libraries\SFEMP3Shield\SFEMP3Snhield.cpp:2092:23: error: 'MP3_DREQINT' was not declared in this scope



But still no joy.

Helpful vid
6 mins
Tech Note 064 - ESP32 How to Connect SPI Devices and Get Them Working


I have got it working now with the Adafruit library and have posted details here :-


SFEMP3Shield library

There are assorted versions.
They don't seem to be supported for ESP32 so it needs assorted code changes to get it to work (which I haven't got to the bottom of)
Configuration of the pins is necessary in the library.
They use SdFat..h
I got confused by all the old information as SdFat looked to have superceded SD.h for the Arduino, which originally had 8.3 file length naming restrictions
but SD.h in ESP32 library is fine.

Go Up