Arduino Forum

Using Arduino => Audio => Topic started by: flossandmeditate on Jun 12, 2019, 06:35 am

Title: PIN setup for vs1053 / ESP32 / MD_MIDIFile
Post by: flossandmeditate on Jun 12, 2019, 06:35 am
Newbie here so please be gentle.

I'm setting up my ESP32 WROOM32 with a VS1053 with inbuilt SDcard to run MD_MidiFile (https://github.com/MajicDesigns/MD_MIDIFile) which uses SDFat (https://github.com/greiman/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..


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
Title: Re: PIN setup for vs1053 / ESP32 / MD_MIDIFile
Post by: marco_c on Jun 13, 2019, 12:18 am
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.
Title: Re: PIN setup for vs1053 / ESP32 / MD_MIDIFile
Post by: flossandmeditate on Jun 25, 2019, 06:11 am
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 (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...




Serial Monitor shows data flowing as I would expect eg...
File: ELISE.MID
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..

Title: Re: PIN setup for vs1053 / ESP32 / MD_MIDIFile
Post by: Hachey on Jun 25, 2019, 12:38 pm

This might help.

http://www.geeetech.com/wiki/index.php/VS1053_MP3_breakout_board_with_SD_card
Title: Re: PIN setup for vs1053 / ESP32 / MD_MIDIFile
Post by: flossandmeditate on Jun 25, 2019, 11:26 pm
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 (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 (https://www.espressif.com/sites/default/files/documentation/esp32-wroom-32_datasheet_en.pdf)
 
Hmmmm.....
Title: Re: PIN setup for vs1053 / ESP32 / MD_MIDIFile
Post by: Hachey on Jun 26, 2019, 04:37 pm
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.

http://www.vlsi.fi/en/products/vs1053.html

http://www.vlsi.fi/fileadmin/datasheets/vs1053.pdf

Plenty of info and clues
http://educ8s.tv/esp32-internet-radio/
He is using this library
https://github.com/baldram/ESP_VS1053_Library

There seems to be two different popular libraries:-

Adafruit
https://github.com/adafruit/Adafruit_VS1053_Library

Sparkfun
http://mpflaga.github.io/Sparkfun-MP3-Player-Shield-Arduino-Library/

https://github.com/mpflaga/Arduino_Library-vs1053_for_SdFat

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
SFEMP3Shield.cpp
SFEMP3Shield.h

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

added this to header file

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

*/
Title: Re: PIN setup for vs1053 / ESP32 / MD_MIDIFile
Post by: flossandmeditate on Jun 27, 2019, 07:30 am
**SOLVED**

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!

https://www.youtube.com/watch?v=7xIEA66e7eI (https://www.youtube.com/watch?v=7xIEA66e7eI)
Title: Re: PIN setup for vs1053 / ESP32 / MD_MIDIFile
Post by: Hachey on Jun 27, 2019, 11:40 am
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

//#define USE_MP3_REFILL_MEANS USE_MP3_INTx

#define USE_MP3_REFILL_MEANS USE_MP3_Polled


But still no joy.


Helpful vid
6 mins
Tech Note 064 - ESP32 How to Connect SPI Devices and Get Them Working
https://www.youtube.com/watch?v=w3VIxtLPuRE



Title: Re: PIN setup for vs1053 / ESP32 / MD_MIDIFile
Post by: Hachey on Jun 30, 2019, 11:35 am
I have got it working now with the Adafruit library and have posted details here :-

https://forum.arduino.cc/index.php?topic=624003.0 (https://forum.arduino.cc/index.php?topic=624003.0)


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.