SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By tom_in_az
#190905
So I am still super new to these Arduino micro controller boards, add ons and various shields. I don't really do any programming yet, but get the idea of modifying someone's example code. In any case, I've been messing with this MP3 Trigger board for a long time now (a few years on and off), and have been trying to introduce WiFi or Bluetooth into the mix. The end goal was to give my robot sounds via wifi connection from my cellphone or tablet. Seems that everyone I've asked just could not give me a straight out answer to get a NOOB going. So I am going to share what I have working so that others may have a slightly easier time making this work.

Materials used:
Sparkfun MP3 Trigger (Firmware v2.54 hex file (zip))
MicroSD card (I used a 2Gb card)
Sparkfun WiFly RN-XV (with 4.41 firmware, request the update when ordering)
SparkFun XBee Explorer Regulated
SparkFun XBee Explorer USB
Headphones (for testing purposes)

Software used:
Tera Term or PuTTY
Arduino IDE 1.6.9
The mobile app that I've been using is called Ardumote or Ardumote HD (available for both Android and on iOS Devices).

Let us start with your RN-XV, if it does not come from Sparkfun with the 4.41 software, then you will need to update it. I urge you to request that your RN-VX module be updated by the Sparkfun Techs as I’ve seen a few of these units brick when being updated. It will save you the time and hassle.

Updating the firmware:
At this point we need to use the XBEE Explorer USB. Plug your RN-XV onto the XBEE Explorer USB and then connect it to your computer. Then start your Terminal program (Tera Term or PuTTY) and open your serial connection to the board.

First we need to be connected to a network that has an internet connection. To do this, I used the following commands (all commands are written in bold).
$$$ [This gets you into CMD mode]
CMD [When you see CMD press the enter/return key to see what firmware you are running]
<2.38.3> [The <2.38.3> is the firmware that some modules come with. Don’t be alarmed if yours is slightly different, we want to get this to say <4.41> in the end.]
<2.38.3> set wlan ssid YourAccessPoint
AOK
<2.38.3> set wlan passphrase YourAccessPointPassword
AOK

<2.38.3> save
Storing in config
<2.38.3> reboot

Next, lets initiate the update over FTP:

$$$
CMD
<2.38.3> ftp update wifly7-441.img
[If a timeout error occurs with the ftp download, try rebooting the chip and wait to see that it connects to your network, before trying the ftp command again.]

<2.38.3> FTP connecting to 198.175.253.161
FTP file=35
................................................................
FTP OK.
UPDATE OK
[MAKE SURE you run this factory reset and reboot straight after the update!]
<2.38.3> factory R
Set Factory Defaults
<2.38.3> reboot
*Reboot**CFG-ERR*
wifly-EZX Ver: 4.41 Build: r1057, Jan 17 2014 10:23:54 on RN-171
MAC Addr=00:06:66:51:0b:0d [your mac address will be different]
*READY*

Now, you’ll need to connect to your network again because it needs to download some more files, so put the chip in ad hoc mode and set up the network:

$$$
CMD
<4.41> set wlan join 1 [Turns on ad hoc mode]
AOK
<4.41> set wlan ssid YourAccessPoint
AOK
<4.41> set wlan passphrase YourAccessPointPassword
AOK
<4.41> save
Storing in config
<4.41> reboot
*Reboot*wifly-EZX Ver: 4.41 Build: r1057, Jan 17 2014 10:23:54 on RN-171
MAC Addr=00:06:66:51:0b:0c
*READY*

Now lets download the extra system files (for more info, see p80 of the manual):
$$$
CMD
<4.41> ftp update wifly7-441.mif
<4.41> FTP connecting to 198.175.253.161
FTP file=58:................................................................
FTP file=59:..................................
FTP file=60:................................................
FTP file=61:.........................................................
FTP file=62:....................................
FTP file=63:...
FTP file=64:.......
UPDATE OK

[MAKE SURE you run this factory reset and reboot straight after the update!]
<4.41> factory R
Set Factory Defaults
<4.41> reboot
*Reboot*
wifly-EZX Ver: 4.41 Build: r1057, Jan 17 2014 10:23:54 on RN-171
MAC Addr=00:06:66:51:0b:0d [your mac address will be different]
*READY*

Now you are updated with the 4.41 firmware!

Time to program up the RN-XV for Access point mode! Connect again to your terminal, and do the following steps:
$$$ [to enter command mode, should respond with CMD and a prompt]
set wlan join 7 [enables Access Point mode]
set ip dhcp 4 [enables DHCP server]
set ip address 192.168.0.1 [or choose any other IP address you wish]
set ip gateway 192.168.0.1 [for iPhone to connect, gateway needs to be the same as the IP address]
set ip netmask 255.255.255.0 [note, only one zero at the end]
set wlan rate 0 [throttle down speed for longest reach, default is 12]
set apmode ssid MyMP3Trigger [or any other name you choose for your Wifi access point name]
set apmode pass yourWiFipassword [set your WiFi password here, at least 8 characters long, max 32]
set wlan channel 1 [or any 2.4GHz channel number you like]
set ip protocol 3 [enables UDP connection mode, required for use with Ardumote]
set apmode link_monitor 0 [disable Deauthentication of clients]
set comm idle 5 [helps for link reconnects]
save [saves settings]
reboot [reboots]

Let us next set up the Arduino Uno board.
Open up the Arduino IDE, make sure you have the UNO board selected, and on the correct com port, these setting will be in the TOOLS menu. At this point we are going to keep this sketch seriously simple!!
We are using a sketch based on Software Serial sketch with a couple of mods:
Code: Select all
/*
 The MP3 Trigger WiFi Circuit:
 Wires from the SparkFun XBee Explorer Regulated are as follows:
 * GND is connected to one of the two ground pins on the UNO
 * 5v is connected to the 5v pin on the UNO
 * DIN is the RX and is connected to digital pin 11 on the UNO
 * DOUT is the TX and is connected to digital pin 10 on the UNO

 Wires from the Arduino UNO are as follows:
 * RX is digital pin 0 and is connected to the MP3 Trigger Board TX
 * TX is digital pin 1 and is connected to the MP3 Trigger Board RX
 
 MP3Trigger changes: 
  * Power switch set to EXT & use external power source
  * Plug in headphones
  * Make sure the SD Card has files on it in the naming convention described in the manual
  *Make sure the MP3Trigger.ini has a baud rate set to 9600.
 
 Modified July 28th, 2016  by Thomas Arroyo IV based on the Software Serial Code by Tom Igoe & Mikal Hart.
 This example code is in the public domain.
 */
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  Serial.println("Serial Connection is active!!");
  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
//mySerial.println("Hello");
}
void loop() { // run over and over
  if (mySerial.available()) {
    Serial.write(mySerial.read());
  }
  if (Serial.available()) {
    mySerial.write(Serial.read());
  }
}

Setting up Ardumote:
* Make sure the lock icon in the lower left is in the unlock position.
* Press and hold the + con in the bottom right press Button.
* In the new window that pops up choose the button on the left with the word Button in it.

Now it is time to set up button parameters:
You will see the new button pop up on your field, press and hold the button and then select Set Parms.
* For the IP address field type: 192.168.0.1 (or whatever IP address you have set up in the WiFly)
* For the Port field type: 2000
* Each button will use a name, for now use: Track 1 for the first button
* For the message field for Track one type: p1
* For the number of sends field set it to: 1
* Press somewhere on the screen outside of the Parameter window to make it go away.
* Press the lock button to lock hour button in place.

Connect your mobile device or tablet:
Power up the Uno, RV-XV, and MP3 Trigger boards.
Associate your mobile device/tablet with your RN-XV access point SSID using the password that you created earlier on.
Once connected open Ardumote and try pressing your Track 1 button.
You should hear 001TRACK.mp3 playing, congrats!

Enjoy making a bunch of buttons to go with your tracks! Again, the buttons can be renamed to help you find your tracks easier. Hope that this makes your first wireless MP3 Trigger soundboard easier to work with!