MP3 Trigger/Decoder Issues

General project discussion / help
Did you make a robotic coffee pot which implements HTCPCP and decafs unauthorized users? Show it off here!

Moderator: phalanx

Post Reply
LH18
Posts: 5
Joined: Wed Aug 15, 2018 4:08 pm

MP3 Trigger/Decoder Issues

Post by LH18 » Sun Sep 23, 2018 2:21 pm

I'm working on a project involving an MP3 player, an Arduino Nano, and switch and am having a strange issue with the MP3 player. I'm wondering if anyone has encountered this and might have a solution.

So far I've made two versions and both have had a similar problem.

Version 1:

Version 1 uses the Qwiic MP3 trigger https://www.sparkfun.com/products/14808 connected to the Nano using I2C, with the SDA and SCL lines connected to Nano's A4 & A5 with a 10k resistor between each line and 3.3 v. Power on the qwiic trigger is connected to 3.3 v as well, gnd to gnd. The nano has a button powered by 5V on one end and connected to D4 and a 10k resistor to ground on the other end. When the button is pressed, the MP3 player plays 3 seconds of audio and then turns off. The Qwiic MP3 player is connected to a small portable pod speaker that has its own battery via the headphone jack. The nano is powered by a 5V external charger (https://www.amazon.com/gp/product/B071G ... UTF8&psc=1) and the speaker is connected to a second external charger of the same variety.

What is really odd is that this setup worked well for about 5+ hours of testing. After a couple of days, however, it started acting unusual and seemed it was turning off every so often. If the power is disconnected and reconnected, it works again for a while. After some additional checking, I found that the power led is on on both the MP3 player and the nano, so it does seem to be getting power. I've tried new batteries, a different pod speaker that works fine with other devices like my computer, I've tried swapping out the nano for an Arduino Uno and continued to have the same problem. At this point, I thought the issue must just be the mp3 board or perhaps there was an issue with the communication between the 3.3V mp3 board and the pins on Arduino (although I had read that this shouldn't be a problem if I2c is run at 3.3v), so I tried a different MP3 player, also SparkX

Sketch of hookup: https://flic.kr/p/28B5SbJ

Code for Version 1:
#include <Wire.h>

byte mp3Address = 0x37; //Unshifted 7-bit default address for Qwiic MP3

const int buttonPin = 4; // button is connected to nano pin 4

int buttonRead = 0; // variable to hold button read

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

Wire.begin();

//Check to see if MP3 is present
// if(mp3IsPresent() == false)
//{
//Serial.println("Qwiic MP3 failed to respond. Please check wiring and possibly the I2C address. Freezing...");
//while(1);
//}
delay(1000); //make sure mp3 received info
mp3ChangeVolume(10); //set volume level, volume between 0 and 31
mp3PlayTrack(1); //start track 1
mp3ChangeVolume(0); //set volume level, volume between 0 and 31
mp3Stop(); //stop playing track 1
}

void loop() {
// read button
buttonRead = digitalRead(buttonPin);

// if switch is activated, turn on audio
if (buttonRead == HIGH) {
// Serial.println("button is activated");

mp3ChangeVolume(10); //set volume level, volume between 0 and 31
mp3PlayTrack(1); //start track 1
delay(3000); //wait for fan cycle
mp3ChangeVolume(0); //set volume level, volume between 0 and 31
mp3Stop();

} else {
// Serial.println("button is LOW");
delay(20); //if button is not pushed, do nothing
}
}

Enter Version 2:

This time I used MP3 Breakout WT2003S and serial communication (https://www.sparkfun.com/products/14810). 5V to 5V on the nano, GND to GND on the nano, MP3 TX to D2 & MP3 RX to D3 (per hookup guide in the example code https://github.com/sparkfun/SparkFun_WT ... no_Library). The same button is connected to 5V on one end and to D4 and a 10k resistor to GND on the other end. What is odd, is that I'm having the same issue. The player worked fine for a bit, and then started doing the same thing where it plays sometimes and other times does not. I added some code to use the serial monitor to see if the button was reading properly and it is. When the setup stops working properly, the button is still reading HIGH or LOW as it should be, but nothing is happening with the MP3 player.

Sketch of Version 2: https://flic.kr/p/2bncWmp

Code for Version 2:

/* Derived from Sparkfun example code by Owen Lyke
Hardware Connections:
WT2003S Breakout Pin ---> Arduino Pin
-------------------------------------
TXO ---> 2
RXI ---> 3
5V ---> 5V
GND ---> GND
BUSY ---> 7 (Needed for busy signal)
*/

#include "SparkFun_WT2003S_MP3_Decoder.h" //include library for mp3 board

const int buttonPin = 4; // button is connected to nano pin 4

int buttonRead = 0; // variable to hold button read

//set status
#define STATUS_PLAY 0x01
#define STATUS_STOP 0x02
#define STATUS_PAUSE 0x03

#define songNameGetDelay 500 // ms

SoftwareSerial mp3_sws(2,3); // Use software serial so that the Arduino hardware serial can be used for control commands

WT2003S MP3; // Create an object of the WT2003S class called MP3

void setup() {
Serial.begin(9600);
while(!Serial){};
MP3.begin(mp3_sws);
MP3.setVolume(1);
MP3.pause(); //test play function
delay(1000);
MP3.stopPlaying(); //stop playing
delay(4000);
}

void loop() {
// read button
buttonRead = digitalRead(buttonPin);

// if switch is activated, turn on audio
if (buttonRead == HIGH) {
Serial.println("button is HIGH");
MP3.setVolume(8);
MP3.pause();
delay(3000); //wait for 3 seconds
MP3.stopPlaying();
delay(1000);
}
else {
Serial.println("button is LOW");
delay(20); //if button is not pushed, do nothing
}
}

LH18
Posts: 5
Joined: Wed Aug 15, 2018 4:08 pm

Re: MP3 Trigger/Decoder Issues

Post by LH18 » Sat Sep 29, 2018 1:03 pm

Update: I believe the problem was actually the micro SD card. I found this completely by accident, switched out the SD card and now the first version at least is up and running. If anyone is trying to put together something similar, version 1 above seems to work well again with the circuit as described and the above code.

Post Reply