Simple arduino code to play .mp3

Discussion in 'Programmer's Corner' started by cmjb13, Oct 16, 2016.

  1. cmjb13

    Thread Starter Member

    Mar 18, 2015
    35
    0
    I have a problem I'm really hoping someone can assist with. I have an Arduno uno connected to an external mp3 module
    http://www.mdfly.com/products/sd-card-mp3-player-module-rs232-ttl.html

    I have all of the wires correctly connected

    I'm trying to get a lone .mp3 file on the SD card called (001.mp3) to play via the below sketch. This sketch appears to be as simple as it gets

    void setup(){
    Serial.begin(4800);
    Serial.write(0x01);
    }

    void loop(){
    }


    I have also tried Serial.write ("001.mp3") to no avail. It's not the SD card as I've tried several and they all do the same thing.

    Any help is greatly appreciated.[/code]
     
  2. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,809
    834
    The documentation is pretty sparse. I've not used this board so it's hard to help.

    What are you using for an amplifier?

    After sending the 0x01, do you need to send a play command, 0xEA?
     
  3. cmjb13

    Thread Starter Member

    Mar 18, 2015
    35
    0
    I have the card connected to speakers.

    I was told by the manufacturer that this should be very simple if connected properly, but for the life of me can't understand why it's not working. I bought this unit based on the apparent simplicity.

    They did give me an additional spec sheet which is similar to the module I have earlier today which I have attached. Apparently this card can only interact with the arduino in which the arduino tells the .mp3 module (with SD card) to play, but the arduino itself does not have direct access to the SD card.
     
    Last edited: Oct 16, 2016
  4. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,392
    497
    From blog post I dug up: http://letsmakerobots.com/node/33537
    1. You need amplifier when using speakers. Headphones are ok without amplifier.
    2. The serial comms are only used for commands.

    From the blog:
    MDfly MOL-AU5121 MP3 player

    [​IMG]

    • uses a standard sized SD card of 32MB-2GB
    • plays audio files in the .MP3 format.
    • 6V-12V power supply (can be used at 5V)
    • stereo output for amplification or use on headphones
    • one-wire serial and parallel communications
    • can store 199 audio files in each of 15 subfolders
    This module is also known as the Tenda TDB380. It is easier to communicate with compared to the SOMO-14D. You can use the 8-bit parallel interface but most will probably want to use the one-wire serial option. All commands are composed of just a single byte. The command byte is sent to the module at 4800 baud. That's it. Simple.

    Whereas the SOMO-14D has an output that can produce audible sound from a speaker in a quiet environment, this one will require an amplifier unless use with headphones is acceptable.

    The datasheet provided by MDfly has the basic information to get you going but isn't a very detailed datasheet. For those that need to know more details I've also provided the manual that Tenda has for the TDB380.
     
  5. cmjb13

    Thread Starter Member

    Mar 18, 2015
    35
    0
    The RS232-TTL does not require an amplifier and I'll explain why.

    When I first ordered the arduino late last year, I was toying around with the sketch for a stepper motor which included playing an .mp3 through the RS232-TTL. I was able to get the audio to work (with standard computer speakers - with 3.5mm stereo jack wires stripped & soldered to .mp3 module). The problem was the randomness of when the .mp3 file would play. I have not been able to get it working since.

    Since the randomness is a problem, I decided to create a new sketch to eliminate the stepper motor code and just verify the .mp3 module is working. That sketch (in my first post) is about as bare bones as it gets. I can't figure out for the life of me why this thing doesn't work...
     
  6. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,809
    834
    Excuse me for not taking you at your word, but your statement that the RS232-TTL does not require an amplifier, concerns me.

    The RS232-TTL pins have nothing to do with the audio.

    So please draw up how you have wired up this module and attach it to this thread. Thanks
     
  7. cmjb13

    Thread Starter Member

    Mar 18, 2015
    35
    0
    Diagram attached. You can ignore the push button as I don't yet have it, but wanted to diagram where it will need to be.
     
  8. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,809
    834
    And how are you powering the modules? In particular, I see no power to the Arduino.
     
  9. cmjb13

    Thread Starter Member

    Mar 18, 2015
    35
    0
    The arduino is connected via external power supply (not pictured)

    MP3 PIN connections
    MP3 PIN 15 to Arduino TX
    MP3 PIN 17 to Right Speaker
    MP3 PIN 18 to Left Speaker
    MP3 PIN 19 to Arduino GND
    MP3 PIN 20 to Arduino 5V (Uno connected to external power supply)

    The K179 stepper motor has it's own power supply
     
  10. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,392
    497
    RS232 does not need amplifier. Blog is not talking about amplifying RS232.
     
  11. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,809
    834
    Ok, (I like pulling teeth, really)...

    But WHAT is the power supply? Are you powering the Arduino through the USB connection? Are you using the barrel jack to get power? Or are you wiring power directly to the Arduino? And of all these, what is the voltage of the power supply? What is it's amp rating? And include anything else about power that I might have forgotten.
     
  12. cmjb13

    Thread Starter Member

    Mar 18, 2015
    35
    0
    External power supply is 9V DC 650mA and connected to arduino barrel jack. I am only using the USB cable to upload sketches, not power the arduino.

    I believe the problem at this point is with the code. The LED on the .mp3 unit when I upload the sketch shows activity and I can hear (what appears to be ) a faint distorted version of the .mp3

    I was able to get the .mp3 file to play only once just the other day with the sketch I use for the stepper motor.
     
  13. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,809
    834
    There is a volume control on the module... perhaps you can connect 2 pins to test that out?
     
Loading...