Introduction: Hack an Old IPod Using an Android and an Arduino.
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.
- Auto Connect - If set, your phone will automatically connect to your MuseHack Station
- Auto Play - Walk in the door and your music will start playing
- Auto Pause - Leave your house and the music pauses for you
- In-Call Pause - Automatically pauses when a call is in session
- Alarm - Wake up to your own music blasting through the stereo
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.
Step 1: Cut to the Chase
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.
- +5V Pin 23 Red (No Stripe)
- GND Pin 16 Black (No Stripe)
- Rx Pin 13 Brown (With Stripe)
- Tx Pin 12 Purple (No Stripe)
- ACC Pin 21 Red (With Stripe)
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.
Step 2: What You Will Need
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.
- 30 pin iPod/iPhone/iPad Device
- Android Device
- Arduino (Uno, Mega, or any Arduino compatible board)
- 30 pin iPod dock extender cable(MUST BE ABLE TO PROVIDE AUDIO/VIDEO, NOT JUST DATA AND POWER) If you get the one used in this tutorial it will make your life a bit easier as the wire colors will match
- HC-05/HC-06 Bluethooth Serial breakout board (AKA JY-MCU)
- 2k Ohm (2 Qty), 4.68k Ohm (2 Qty), 500k Ohm (1 Qty) Resistors
Link is for a whole mess of resistors of which include the above
- MuseHack App for Android
- Jumper wires
- Wire Strippers/Cutters
This is really the only tool that is required.
Not Required but may be helpful:
- mounting plate or project box
Radioshack actually has a decent selection of project boxes The box used in the tutorial is about 4 x 6 x 2 in.
- Electrical tape
- Binder clip
- Soldering iron
Step 3: Communication
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.
Step 4: The HC-05/HC-06 Bluetooth Module
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:
Step 5: The IPod Devices
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:
- +5V - Pin 23
- GND - Pin 16
- Rx - Pin 13
- Tx - Pin 12
- Acc - Pin 21
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:
- A voice recording mode. This is unused in this project
- A simple mode. This consists of basic commands. (Play/Pause, Skip, Volume, Select, etc)
- The Advanced iPod Remote mode (AiR Mode) This allows for data to be sent to and collected from the iPod. (No Volume Control)
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 header (0xFF, 0x55) - Every command starts with this exact header.
- The Size of the command - This byte represents the number of following bytes excluding the checksum.
- The Mode of the command - This project uses mostly mode 4 with a few mode 2 commands in there.
- The Command - Two bytes specific to the instruction sent/received. In mode 4, the first command byte is usually 0x00.
- The Parameters - Up to 9 parameters can be sent containing details of the command
- The Checksum - This byte is used for error checking.
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.
Step 6: The Tricky Part.
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:
- +5V Pin 23 Red (No Stripe)
- GND Pin 16 Black (No Stripe)
- Rx Pin 13 Brown (With Stripe)
- Tx Pin 12 Purple (No Stripe)
- ACC Pin 21 Red (With Stripe)
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.
Step 7: Wiring
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.
Step 8: Set Up the Voltage Dividers.
- 2K Ohm (2x)
- 4.68K Ohm (2x)
- 500K Ohm (1x)
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.
Step 9: Connect the HC-05 and IPod Wires
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
Step 10: The Code
****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 Macro
- Declare global variables
- iPod Message Handling Variables
- iPod Commands
- Droid Message Handling Variables
- Droid Command Addresses
- Timers (Unsigned Long)
- Software Serial Initialization
- Function Prototypes
- Setup Function
- Main Loop Function
- Connection Handling Functions
- Droid Data Receiving Functions
- iPod Data Receiving Functions
- Volume Adjust Function
- Data Sending And Receiving Functions
- Debug Led Functions
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.
Step 11: Finalize
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.
Step 12: Extra Credit
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.
Step 13: The App
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.
Step 14: Troubleshooting
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
- Check that the Rx and Tx pins (D0, D1) are clear. These are the lines used uses to upload your sketch to the ATMega328P MCU on the Arduino.
Able to send data and use the basic features (play, pause, skip, etc) but not receive any data (song name,
- Check the Rx connection from the Arduino to the iPod (purple). Try to make sure all connections are tight, those tiny stupid wires in the cable can be difficult to seat in the breadboard.
Able to receive data and get song name and artist but not able to use any features
- Check the Tx wire from the Arduino to the iPod (voltage divider to brown) for connection issues.
Pop up on iPod says it does not work with this device
- Check the value of the resistor from the red with stripe wire from the iPod through the resistor to the GND rail. This should be 500K Ohms. If it is not, the iPod will think that it is connecting to a different device other than MuseHack.
(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
- Check your connections and make sure all wires are seated snugly and ensure no wires are touching that shouldn't be.
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
- Disconnect from MuseHack, find Bluetooth through your phone's settings, manually do a scan and pair with the found HC-05 device
iPod constantly switching modes (Screen displays "Ok To Disconnect" then back again.
- If the 30 pin connector does not sit right it will jump back and forth from screens. I had an iPhone 3 that did not fit right with one cable but another did. Might need to invest in a new cable.
If using an iPad and it is plugged in and nothing is playing even though it says there is.
- Try unplugging the headphone jack and plug it back in.
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.
- When pairing using Android 2.3 you may have to access the pair request from the settings menu or the drop down menu since the dialog box does not appear when requesting a pairing.
iPod shows the start up apple then shuts down and repeats.
- If you are using an iPod with a very dead battery, one that dies instantly when you unplug it, you may have to use power from a power supply (phone charger or barrel plug supply) from an outlet instead of the computer.
I have personally tested this code and the app with:
- iPod mini
- iPod 5G color
- iPod touch
- iPhone 3
- iPad 2
- HTC Incredible API 2.3 (Gingerbread)
- HTC Desire API 2.3 (Gingerbread)
- Dell Streak Tablet API 3.2 (Honeycomb)
- Galaxy SIII 4.2 (Jellybean)
- Galaxy S5 4.4 (Kitkat)
If you have questions or to report bugs, please email me at:
and I will do my best to answer/fix them.
We have a be nice policy.
Please be positive and constructive.