This tutorial shows you how to use an Arduino to turn that old dusty music player into a Bluetooth controlled docking station.
Even if it has a cracked screen or a dead battery it can still be used.
The following instructions will show you how use an Arduino and a couple of cheap parts to set up a MuseHack station NO SOLDERING REQUIRED!!!
This project can be built for under $25 which includes buying an Arduino.
Just leave the old Ipod plugged into the stereo and your music will start to play when you walk in the door.
The Arduino acts as a liaison between the iPod and your Droid.
Since the iPod device is connected directly to your stereo, it eliminates any error that can occur when streaming the music to a separate device.
iPod, iPad, and iPhone are trademarks of Apple Inc., registered in the U.S. and other countries.
If you want to just get after it, you can download the code and wire it according to the above image.
The wire colors correspond to the cable suggested by this tutorial.
Here is the app:
The Bluetooth pairing pin is 1234
For Arduino Uno - The digital pins 0 and 1 (Rx and Tx) must be clear when uploading the sketch.
This is really all you need to complete this project. The rest of this tutorial just rambles on a bit.
To start, you will need a fully functional Android powered device and at least a semi functional iPod, iPad or iPhone that uses the 30 pin connector. Having music on it helps
The ebay links provided are the cheapest of these items I could find and may be outdated but can point you in the right direction. For reliability I have also provided a few amazon links.
Link is for a whole mess of resistors of which include the above
This is really the only tool that is required.
Not Required but may be helpful:
Radioshack actually has a decent selection of project boxes The box used in the tutorial is about 4 x 6 x 2 in.
Both the iPod and the HC-05/06 Bluetooth module use serial communication to talk to the Arduino.
The Atmel MCUs used on the Arduino come with a UART (Universal Asynchronous Receiver/Transmitter) built in.
The UART is a peice of hardware that will take bytes of data and sequentially transmit them in single bits. The receiving UART will reassemble the bytes.
For more on UART/USART
If you are using an Arduino with only one serial port (ie. Uno, Leonardo), the SoftwareSerial library will be used.
If you are using the Mega, multiple serial ports are supported and there is no need for the SoftwareSerial library.
The Arduino code will adapt if using a board with multiple serial ports. This will be covered later in the code section.
From here on out I will be referring to this Bluetooth device as the HC-05.
You will not have to worry about the details of the HC-05 for building this project since the factory settings are used. Just plug and play.
The main difference between the HC-05 and HC-06 is its ability to be set from the slave role to the master role. All HC-XX modules, where XX is an even number, come from the factory in the slave role and cannot be changed. On the other hand, all modules, where XX is an odd number, can be set to the master role using AT commands. The HC-06 and other even numbered modules also have a limited number of AT commands available for setting preferences compared to their odd numbered counterparts.
For more information on Bluetooth technology, the Bluetooth website is very informative:
The iPod is a versatile little mp3 player and can be used with many different accessories. Those 30 pin connectors hold pins for Docking stations, firewires, USB and more. In this case we are using the Serial Rx and Tx pins.
That dock extender cable is used because it has connections for those pins as opposed to the normal usb connection which only has +USB data -USB data VCC and GND.
The connector is a JAE DD1 30 pin connector.
This project will use the following 5 pins:
The Acc pin is pulled low through a resistor, and depending on the resistance, the iPod will know what type of accessory it is attached to and how to communicate accordingly.
A list of all the pins and what they do can be found at:
The Apple accessory protocol is used to communicate with the Ipod. The standard 8N1 serial configuration is used. 8N1 specifies that there are 8 data bits, No parity bit, and 1 stop bit. This configuration is what the Arduino assumes when you establish the baud rate for transmission (ie. Serial.begin(9600);). This can be changed by adding a configuration argument to that call (ie. Serial.begin(9600, SERIAL_5N1);).
In this project we will just be using the standard 8N1 configuration.
This project will communicate at a baud rate of 9600.
The iPod can be put into 3 different modes:
When in AiR mode, the screen will give you the "OK to disconnect" status on the older generation iPod. The iPhone 3, iPod touch and iPad do not show this screen and allow you to control it from both the app and the iPod itself.
AiR mode is typically used when connecting to an accessory that processes the data to an audio signal, and the volume control is all done through that accessory.
Since MuseHack uses the headphone jack while in Mode 4 (Air Mode), volume adjustment becomes a little tricky. This is accomplished by momentarily switching back to mode 2 to adjust volume before returning to mode 4.
This will be covered in more detail in the code section.
Adriangame provides a well laid out description of the protocol used to talk to the iPod:
Every command sent to the iPod contains at least 5 items in byte form.
The checksum byte sums the value of the bytes from Mode to the end of the parameters.
This sum is then subtracted from 0x100 (256). Since the sum can be greater than 0xFF (255) and we only want the lower byte, the bitwise operator & is used with 0xFF to shed the higher bits.
(ie. checksum = (0x100 - sum) & 0xFF)
This is the method used by the iPod but is only one way to calculate a checksum.
The most difficult part of this project is locating the correct pins and their attached wires..
First, you must cut that brand new dock extender cable.
Remove the Female connector end of the cable. You will be using the connector that plugs into your iPod.
Be sure to leave enough cable to allow for mistakes.
Also, when the project is finished, some extra cable is nice since it allows the connected iPod to be a little more movable.
Pull the shielding away from the wires and remove it exposing the individual wires.
There are two layers. A foil wrapping around the wires and a braided bare wire around that. Both need to be removed.
Strip away the coating
The cable I used contains 24 gauge wires. These tiny little wires can be difficult to strip since the average wire strippers only go as small as 20 or 22 gauge. Automatic wire strippers do a pretty good job with these little wires. If you do not have access to automatic wire strippers, teeth work well. If you value the integrity of your teeth, using a soldering iron is another method that works fairly well. I get the iron hot, lay the wire flat on a metallic surface, press the hot tip on the wire where you want to begin stripping, when it starts to smoke gently pull the wire while holding the iron in place.
If you are using the cable in this tutorial, there is no need to strip all of the wires. Just single out the wires differentiated by color and you can skip the next paragraph.
The Cable suggested by this tutorial uses the following color coding:
Locate the desired 5 wires
This is where a multimeter comes in handy.
Using the continuity setting, connect one lead of the multimeter to the exposed wire on one end, and locate the corresponding pin on the 30 pin connector by touching the other lead of the multimeter to the pin.
Some of the wires use the same color. There is actually a tiny stripe on one of those duplicated colored wires. This stripe can be difficult to see but it is pertinent you do so.
Once you are sure you have the correct wires selected, go ahead and remove the unused wires from the group.
Since both the HC-05 and the iPod device use a 3.3V logic signal, and the Arduino puts out a +5V signal, a couple voltage dividers are needed.
The easiest way to go about this is to just follow this wiring image.
The legs of the resistors are quite long, cutting them to a length that allows them to sit right up against the bread board makes the wiring a bit more manageable.
Start by running the two 4.68K Ohm and the 500K Ohm resistors to the GND rail.
Next position and insert the two 2K Ohm resistors so one of the legs is connected to the non Grounded side of the 4.68K Ohm resistors and the other is in its own terminal.
The way I have it set up in the above picture keeps things separated and makes life a little easier down the road.
Plug the HC-05 into the bread board so the Voltage divided Tx line (D3 Uno, D16 Mega) from the Arduino is connected to the Rx of the module and the Tx line of the HC-05 is connected directly to the Rx line (D2 Uno, D17 Mega) of the Arduino.
Connect jumpers from the +5V and GND rail of the bread board to the VCC and GND pins of the HC-05.
For the Ipod, onnecting the tiny wires of the dock extender cable can be difficult.
I found that using the leg of a resistor to push the wire into the terminal helps.
Connect the Voltage divided line (D1 Uno, D18 Mega) from the Arduino to the Rx of the Ipod (Brown with stripe) and the Tx line of the Ipod (Purple no stripe) directly to the Rx pin (D0 Uno, D19 Mega) of the Arduino.
Connect the ACC line of the iPod (Red with stripe) to the 500K Ohm resistor leading to the GND Rail.
Finally connect the +5V (Red no stripe) and GND (Black no stripe) to the power rail.
For a better connection, clip and strip a couple jumper wires and connect them to the end of the dock extender cable wires to give you something real to push into the breadboard.
This is not necessary but it helps a lot.
If you have the option to solder them it makes the connections even stronger.
The above pictures demonstrate this process.
At this point you can feed it some power.
The HC-05 should start blinking
****When uploading to the Arduino Uno, The Rx and Tx pins D0 and D1 must be clear
The code is a bit lengthy but you can simply save it then open it from your IDE and upload.
There are plenty of comments throughout the code that will hopefully help to clarify some of the madness.
Keeping the iPod on a hardware UART as opposed to the SoftwareSerial proved to have much more reliable results.
The Code is structured as follows:
The list of function prototypes is in the order they appear in the code and can be used like a table of contents.
If you are using an Arduino that supports multiple serial ports, you can uncomment the #define DEBUG constants to have it print debugging information to the serial monitor.
There are two types of debug print options, DEBUG and DEBUG_DETAIL.
DEBUG will print the basic operations while DEBUG_DETAIL will print the transmitted data as well.
With both uncommented, the rate of incomming data can be a little overwhelming. Commenting out individual DEBUG_PRINTs throughout the code can help with this.
When you are using a board with only one serial port, placing the debugLEDOn() function throughout the code will set Pin 13 high and turn on the attached led when it gets hit.
Now that everything is connected make it look pretty.
If you are fine with how it is now, I would recommend attaching a binder clip to the base plate to hold the dock extender cable in place so you don't lose any connections if it gets pulled.
If you want to make a slightly more contained fixture, mount the Arduino and breadboard in a project box.
Once you have them lined up in the box, drill a couple holes. One for the power to the Arduino, and one for the dock extender cable. I also made a couple pilot holes in the base for mounting the boards with small screws
Once the cable has been threaded through the hole, tie a knot in it before reconnecting it to the breadboard. This will help if the cable gets pulled.
If you would like to increase the Bluetooth, range here is a little trick
**This step requires soldering.
The range gained from doing this is not significant but it does help a little.
This requires borrowing a 2.4 Ghz antenna from some device.
Antennas are designed for specific frequencies. Since Bluetooth operates in a 2.400 to 2.4835 GHz range, this antenna will work.
I found and used an old router that was sitting in the garage.
Open it up and remove the antenna.
Unmount the antenna.
De-solder the connections.
Scrape off all but a little of the HC-05 antenna as pictured above. You do not want that extra length.
Solder the inner wire of the antenna to the little bit of antenna remaining on the HC-05 and solder the shielding to the GND pin.
The remaining antenna on the HC-05 after scraping the rest off is quite fragile so be sure to secure you solder job. Either hot glue or tape works.
Cut a hole in your project box and mount your new antenna.
Open the MuseHack app and press the connect button.
This will bring up a dialog box with a big ol scan button. Press it
The app will then begin to search for discoverable devices.
The new devices will appear at the bottom of the box. It will most likely have the name "null" or "HC-0X" with a 12 character address below it.
After selecting it, a pairing request will pop up.
Enter pin 1234
This is the factory set pin.
If the pairing screen did not come up, you may have to find it from the top pull-down menu or in the Bluetooth menu in your phone's settings.
Once paired and a socket has been made, the blinking light on the HC-05 will turn solid.
Plug the extender cable into your iPod.
After a few seconds, the MuseHack app screen should read the artist name, song name etc of the either the most recently played song or the first song from your entire library depending on how you last left the iPod.
If this does not happen please refer to the troubleshooting section.
If you built it successfully, plug your stereo into your iPod, blast it and celebrate saving the environment by not throwing away an iPod....or something.
Congrats. You're done.
Setting up the preferences can allow for auto connecting, auto pausing and alarm setting.
The Auto Connect is based on your connection to your home wifi.
Because constantly scanning for a discoverable Bluetooth device is resource expensive, the app will wait until your home wifi automatically connects before scanning for the previously chosen HC-05.
This can be setup by selecting the preferences option from the popup menu, tapping Auto Connect settings and checking the Auto Connect check box.
Doing this will make the next two selections available.
Make sure your wifi is turned on, tap Home WIfi Network and select your home network.
Once you have paired with an HC-05, you will have the option of selecting it from the list of other paired devices under the MuseHack Bluetooth Device option.
The Auto Play option below that will tell the iPod to play once it has established a connection.
The Auto Pause feature allows you to just up and leave without thinking about the music. If set, the music will continue to play from 1 minute to up to 30 minutes before pausing depending on your settings.
The Alarm feature allows you to set a time for when the music will begin to play. I have found it is much more pleasant to wake up when my favorite chill song hits the main speakers rather than an annoying stock alarm.
The primary cause of most problems will be poor connections. There is data constantly being sent to and from both the iPod and the Droid. If this gets interrupted it can cause issues.
Please make sure all the connections are in the right place and are secure before emailing me.
Remember the HC-05 falls under the Bluetooth power class 2 and has a range of 10 meters (about 30 feet).
This range greatly depends on obstacles, If you live in a lead house I don't imagine your range will be spectacular. On the Other hand if you live a stadium you can have a lot more freedom.
Also, remember volume control takes the iPod out of AiR mode to adjust the volume before returning to AiR mode. While it is in Mode 2 the other controls will temporarily be unavailable.
The program will not load to the Arduino
Able to send data and use the basic features (play, pause, skip, etc) but not receive any data (song name,
Able to receive data and get song name and artist but not able to use any features
Pop up on iPod says it does not work with this device
(If the iPod or iPad or iPhone says " This Accessory is Not optimized for this iPhone", this is OK)
If the app is disconnecting frequently or the iPod stops playing then restarts
If you have to scan for devices every time to find the the HC-05 because it does not appear in the list after pressing connect
iPod constantly switching modes (Screen displays "Ok To Disconnect" then back again.
If using an iPad and it is plugged in and nothing is playing even though it says there is.
The app will not find the HC-05 at all.
Try restarting the Android device. This will usually work, if not, then unfortunately you may have to get another HC-05. I had an HC-05 that any Android running 2.3 would not connect to but all other versions of Android worked fine. I had another identical HC-05 that I put in its place and the Android 2.3 devices connected just fine.
After selecting the HC-05 from the device list, the connecting box stays or it appears to connect but nothing happens.
iPod shows the start up apple then shuts down and repeats.
I have personally tested this code and the app with:
If you have questions or to report bugs, please email me at:
and I will do my best to answer/fix them.