Sending Music from iPhone to Arduino

Hi everyone!

I am still pretty new at using Arduino, but I have been trying to look into a way to send music to my Arduino from my iPhone. Ideally, I wanted to get it to send the data through the Lightning-USB cable--similarly to how my car (USB) receives music from my iPhone (Lightning).

I've been looking at a lot of articles, forum threads, etc. and what I've been looking into is using a

USB Host Shield:
www.amazon.com/arduino-org-A000004-Arduino-Host-Shield/dp/B00LUJYN5S/

or maybe a
USB 2 Serial Light:

I also saw this connector Redpark TTL Serial Cable for iOS but it didn't seem to have good reviews, and I am not sure if using one of those cable pin converters would make that work.

I notice that others have connected their iPhones to the arduino board, but I wasn't able to find more info on straight up music transfer.

I found some information on how to set up music streaming:

This was, atleast from what I know, the closest thing I could find to what I want to do:

however, I don't know have an old iPod dock, and this isn't using Lightning.

I read a lot of other threads as well, but I really wasn't able to figure out the way to do this. As mentioned earlier, I am pretty new at this, so maybe I missed/didn't understand something? Would someone be able to give me some guidance on how I can accomplish this?

I currently have an Arduino Micro but will probably be getting an Arduino Mega sometime soon.

Thank you so much,
Lien

What would the Arduino do with the music?

Note that playing audio through an Arduino produces very poor quality sound.

I don't think you can get an iPod to send audio digitally through the USB. If you can then you need a host shield, but I think your project is a no go.

jremington:
What would the Arduino do with the music?

Well basic functionality is that it would then send the data through another port to the USB port in my car. You may ask why I don't just plug my phone directly in. For now, I want to just be able to do that, before I work towards building something more with that.

Grumpy_Mike:
Note that playing audio through an Arduino produces very poor quality sound.

I don't think you can get an iPod to send audio digitally through the USB. If you can then you need a host shield, but I think your project is a no go.

Even with an MP3 Decoder Shield and an USB Host Shield? I figured that with the USB Host Shield, I could connect the phone to the TX RX lines. From there I could send the data through the MP3 Decoder Shield which would take care of the audio handling.

It would be a real bummer if I wasn't able to do that :(. I've clearly seen people do projects where they connect their phone to the Arduino using Bluetooth. If that is possible, why not USB?

Thanks for all your help!
Lien

Edit: Since I am seeing a lot of Bluetooth Audio Streaming, I was wondering if you knew of any relatively cheap Bluetooth Audio Boards that work with Arduino. I found this, but if I want to make 4 devices, I'd hate to have to spend $45 on each.

As always, I appreciate all the help!

I figured that …

You don’t have much of an idea about how things work.

It would be a real bummer if I wasn’t able to do that

Yes it is.

've clearly seen people do projects where they connect their phone to the Arduino using Bluetooth. If that is possible, why not USB?

Because the iPhone has no way of sending audio data out of the USB port. Bluetooth is different it is used for remote head sets so they designed that function into the phone. Try it yourself - try sending uncompressed sound data out through the USB.

Even with an MP3 Decoder Shield and an USB Host Shield?

There is an assumption here that you can make the iPhone send data in MP3 format. I do not believe that that is a valid assumption.

What DO you know about programming iPhones? If nothing is the answer, move along. Find another project.

Grumpy_Mike:
Because the iPhone has no way of sending audio data out of the USB port. Bluetooth is different it is used for remote head sets so they designed that function into the phone. Try it yourself - try sending uncompressed sound data out through the USB.

This confuses me.
I say this because I can plug in my iPhone via it's Lightning to USB cable into my car audio receiver. I can then press a button(technically a graphical representation of a button on the receiver's touch screen I suppose) on the receiver and browse/play through the receiver the audio files I have stored on my iPhone. So it sure seems like the audio data in the audio data file (MP3, ACC etc) is being transferred via the USB cable. And if I unplug the cable the audio playback stops, which would indicate that USB connection between the two devices is pretty critical. Bluetooth was disabled on my iPhone when I tested this on my grocery run earlier today, and my car audio receiver does not support WiFi. So USB was the only link between the iPhone and car audio receiver.

I also don't understand why you would suggest sending uncompressed audio data. Uncompressed audio data is not an efficient medium for audio data on a limited storage device such as an iPhone.
Can much of the population discern an audio quality difference between a decently encoded FLAC/ALAC file and a WAV file? I can't. But I'm no longer young.

Now an Arduino being fast enough to process the audio data in real time with any level of acceptable audio quality is a totally different issue. But I question that the audio data output via USB of the iPhone would be the limiting factor.

I can plug in my iPhone via it's Lightning to USB cable into my car audio receiver.

Some devices are USB Masters (aka USB Hosts). Some are USB slaves. Some can (probably) be both.

Which role is the "iPhone via it's Lightning to USB cable" playing? Which role is the car audio receiver playing?

Which role is the Arduino (a USB slave unless external hardware is added, which requires code to drive it) going to play?

PaulS:
Some devices are USB Masters (aka USB Hosts). Some are USB slaves. Some can (probably) be both.

I don't disagree with that statement.

PaulS:
Which role is the "iPhone via it's Lightning to USB cable" playing? Which role is the car audio receiver playing?

If I were to guess I would answer that the car audio receiver is acting as a host. It requests from the iPhone a list of available audio data. Then based on user input into the car audio receiver it sends a request to the iPhone to stream the requested audio data. Since the iPhone is not initializing the communications but only reacting to requests from the car audio receiver I think that would indicate the iPhone is fulfilling the role of slave. I could be completely wrong though.

PaulS:
Which role is the Arduino (a USB slave unless external hardware is added, which requires code to drive it) going to play?

With the OP's mention of a USB host shield I lean towards the idea of the Arduino acting as host.

However, the role of the Arduino is not what my post you quoted was addressing.
I was commenting on the idea that it is not possible for an iPhone to pass audio data via USB. From my experience it does seem to have the ability to pass audio data via USB. Unless you or someone else can explain how the data is getting from the iPhone to the car audio receiver's speaker outputs with the only link between the two devices being USB, yet somehow the audio data is not being passed through USB I will continue to hold the position that the audio data is in fact passed from the iPhone via USB.

So as far as the OP's project getting the audio data out of the iPhone is not the limiting factor. The Arduino's limited programming space and execution speed of passing the audio data are much bigger hurdles that might prove difficult to overcome.

This is not to say I believe that a basic Arduino would be the best device to act as host even with a USB host shield.

Like i said, I am very new at this! I just started about a month ago--which is why I am asking questions...

Yes, I might not know how all the parts work, but I am trying to learn. Telling me that I don't have much idea about how things work doesn't help anyone.

Also, I'm not one to just move on. What kind of attitude is that? Hey, I don't know how to do something--let me just give up. Absolutely not. I might not know how to do something, but I'll be damned if I don't try and figure it out. Honestly, that is why I came here. I want to learn! You've got to start somewhere...

I simply thought, that if my car, just like Frostline's car, can send audio straight through the USB-to-Lightning cable, I might be able to pass it through the Arduino. At first, I thought I'd just try it to send data through to the Arduino, and for the Arduino to send it back out through another USB port--unaltered. Then from there, I could try different things!

I have stored an MP3 on an SD card, read it using the Arduino, and sent it to some headphones. Yes, the connections and process are probably different. I am just trying to figure out how to do that with USB (like so many cars do now a days) rather than SD.

If my car can take any phone that I've tried (multiple Android and iPhone models) and play whatever audio (Youtube, Spotify, music, random videos) it is playing through the car speakers using only a USB-to-Lightning or USB-to-MicroUSB cable, I just don't see how passing audio data through a USB is not possible.

Your biggest stumbling block is authentication. iPhones will only spit out digital/USB audio if they get the correct handshake from the device it's connected to. Car manufacturers have to pay Apple for the required authentication chips for this to work.

If you use a lightning to 30 pin adapter cable, you can still access the serial port (for control) and get analog audio. It's even possible that the car is doing this under the covers, and you're not actually getting digital audio.

The genuine Apple lightning to 30 pin adapters contain a DAC, and the required authentication chip to allow this.

Ian.

ian332isport:
Your biggest stumbling block is authentication. iPhones will only spit out digital/USB audio if they get the correct handshake from the device it's connected to. Car manufacturers have to pay Apple for the required authentication chips for this to work.

If you use a lightning to 30 pin adapter cable, you can still access the serial port (for control) and get analog audio. It's even possible that the car is doing this under the covers, and you're not actually getting digital audio.

The genuine Apple lightning to 30 pin adapters contain a DAC, and the required authentication chip to allow this.

Ian.

Wow, great! Thanks for that information. So if I were to get the genuine adapter, auth chip, and then connect it to my Arduino, would I be able to retrieve the audio data? What exactly do you mean by for control? Like how my car can send my phone play/pause/next commands? I can still get the audio right?

Any idea where exactly I could get one of these chips? I read about this. Is this what you are talking about?

Actually, I think it is what is detailed here in this PowerPoint about using iPhones to make Loudspeakers.

It says that I have to register as an MFI developer. However, when you go to apple's website, they clearly say that for personal use, you should use a third-party hobbyist solution. Any idea what they are exactly referring to?

Is it possible for me to just piggyback on my car's request for authentication? Basically, make the Arduino a sort of USB extender? (Don't jump on me for asking this question--I just don't know if that is possible).

A cool article I read was about these headphones that connect directly to your lightning port. From what you said, and from what I read, it seems like they are using Apple's MFi system. I'm just curious what Apple refers to when they say "third party hobbyist solution" for personal use.

What about Android? Do I need this sort of authentication for Android?

Thank you so much, Ian! I am going to keep researching this and see what I can do.

Lien

Lien:
So if I were to get the genuine adapter, auth chip, and then connect it to my Arduino, would I be able to retrieve the audio data?

The genuine adapter contains an auth chip that allows the adapter to provide analog audio. You won't be able to get an auth chip alone, unless you sign up to the MFI program, and part with a ton of cash.

What exactly do you mean by for control? Like how my car can send my phone play/pause/next commands?

Yes, you can send commands to the iPod/iPhone serial port to control audio playback.

I can still get the audio right?

Yes, bus as above, it will be analog, not digital audio.

Any idea where exactly I could get one of these chips? I read about this. Is this what you are talking about?

That pretty much explains the problem. I doubt it's possible for an individual to get an auth chip direct from Apple.

they clearly say that for personal use, you should use a third-party hobbyist solution[/url]. Any idea what they are exactly referring to?

Possibly one of the cable solutions from Redpark, but only a guess.

Is it possible for me to just piggyback on my car's request for authentication? Basically, make the Arduino a sort of USB extender? (Don't jump on me for asking this question--I just don't know if that is possible).

Not sure to be honest, but I doubt it.

What about Android? Do I need this sort of authentication for Android?

I don't believe Android has any of these problems.

Cheers,

Ian.

ian332isport:
The genuine adapter contains an auth chip that allows the adapter to provide analog audio. You won't be able to get an auth chip alone, unless you sign up to the MFI program, and part with a ton of cash.

Yes, you can send commands to the iPod/iPhone serial port to control audio playback.

Yes, bus as above, it will be analog, not digital audio.

That pretty much explains the problem. I doubt it's possible for an individual to get an auth chip direct from Apple.

Possibly one of the cable solutions from Redpark, but only a guess.

Not sure to be honest, but I doubt it.

I don't believe Android has any of these problems.

Cheers,

Ian.

Thank you for such a detailed response!

You say that the genuine adapter contains an auth chip? So does that mean that it can retrieve the Audio from the phone using that? How would I "tell" the phone to send the audio through the cable, rather than playing through the iPhone speakers?

From what I read online, the Lightning cable automatically converts audio to digital. How would I be getting the audio via analog (unless you mean it playing straight through the iPhone speakers)? Maybe I could use an ADC to convert it?

Regardless of all of these, I am going to at least try and see if maybe I can make the Arduino act similarly to a sort of a USB Female to Female (kind of like a USB extender), and let my car send the MFi handshake and have it pass directly through the Arduino to the phone. If I can get that to work, I should then be able to get this to work as long as I have an MFi device on receiving end. I really don't know if it will work, but its definitely worth a try.

Thank you so much for your help! You guided me into new information that I could research and learn about. I really appreciate that :smiley: .

Lien

Edit: Oh, and if I can't get it to work with iPhones, I will also try an Android device and see what I can do.

Lien:
You say that the genuine adapter contains an auth chip? So does that mean that it can retrieve the Audio from the phone using that? How would I "tell" the phone to send the audio through the cable, rather than playing through the iPhone speakers?

Back in the days before the Lightning connector came along, you had the standard 30 pin dock connector. On this connector, you could get analog audio without any authentication, or digital audio (via USB) with authentication. When apple introduced the Lightning connector, they completely removed the option of analog audio from the connector. To allow existing audio docks/speakers to function, they produced the Lightning to 30 pin adapter cable. This contains the authentication chip which tells the iPhone to output digital audio. The adapter also has a built in DAC to convert the digital audio to analog, so older hardware will still function.

You can certainly retrieve this audio signal and use it how you wish. As long as you understand that it's been converted to analog, you should be fine. I don't think there's any simple way to access the digital audio stream.

To tell the phone to output the audio through the dock connector, rather than the iPhone speaker, you need to connect a pin to ground (pin 11 I think). There's plenty of dock connector pinouts online.

From what I read online, the Lightning cable automatically converts audio to digital. How would I be getting the audio via analog (unless you mean it playing straight through the iPhone speakers)? Maybe I could use an ADC to convert it?

You've got it the wrong way around. The Lightning to 30 pin adapter cable converts digital to analog using a DAC.

Frostline:
This confuses me.
I say this because I can plug in my iPhone via it's Lightning to USB cable into my car audio receiver. I can then press a button(technically a graphical representation of a button on the receiver's touch screen I suppose) on the receiver and browse/play through the receiver the audio files I have stored on my iPhone. So it sure seems like the audio data in the audio data file (MP3, ACC etc) is being transferred via the USB cable.

USB devices can be everything, from HID (mouse...), COM port, to memory sticks. Each device type uses a specific protocol for data exchange. The Arduino Uno/Mega USB acts as a COM port, and only as a COM port. The Leonardo can act as a HID as well, when programmed accordingly.

Your iPhone, more precisely the Lightning cable, seems to act as a different (MP3?) device, not compatible with USB devices of other types. Connecting it to an Arduino USB connector will not allow the Arduino to receive any data, because it can communicate only with other USB COM ports.

Sticking one USB connector into another USB connector unfortunately does not automatically allow both devices to speak to each other. When you e.g. stick your Lightning USB into a PC USB, Windows will search for the required driver. You're lucky when the required driver is found, otherwise the connection is inoperative. Since an Arduino does not have an USB driver library, it cannot communicate with your iPhone this way :frowning:

ian332isport:
Back in the days before the Lightning connector came along, you had the standard 30 pin dock connector. On this connector, you could get analog audio without any authentication, or digital audio (via USB) with authentication. When apple introduced the Lightning connector, they completely removed the option of analog audio from the connector. To allow existing audio docks/speakers to function, they produced the Lightning to 30 pin adapter cable. This contains the authentication chip which tells the iPhone to output digital audio. The adapter also has a built in DAC to convert the digital audio to analog, so older hardware will still function.

You can certainly retrieve this audio signal and use it how you wish. As long as you understand that it’s been converted to analog, you should be fine. I don’t think there’s any simple way to access the digital audio stream.

To tell the phone to output the audio through the dock connector, rather than the iPhone speaker, you need to connect a pin to ground (pin 11 I think). There’s plenty of dock connector pinouts online.

You’ve got it the wrong way around. The Lightning to 30 pin adapter cable converts digital to analog using a DAC.

Oh okay, got it! If I’m not mistaken, the analog inputs on Arduino already are ADCs, correct? So I can take the adapter, hook it up to the lightning cable, connect it to ground, and the phone should send analog music to through, right? Then I can retrieve the analog data using an analog pin on the Arduino?

My adapter should arrive by Friday, so I will definitely try it this weekend!

Thanks,
Lien

Lien:
Oh okay, got it! If I'm not mistaken, the analog inputs on Arduino already are ADCs, correct?

They are, but not for audio with any sort of quality.

So I can take the adapter, hook it up to the lightning cable, connect it to ground, and the phone should send analog music to through, right? Then I can retrieve the analog data using an analog pin on the Arduino?

If you plug the adapter cable into the phone, and connect the correct pin of the 30 pin dock connector to ground, it should play audio through the audio output pins on the dock connector. I'm not sure where the Arduino fits into this though.

To play music in Arduino, instead of sending music from iPhone, you can also access to music library via USB flash drive.
Take Spotify music as example, if you'd like to send Spotify music to Arduino, you can firstly use AudFree Spotify Converter to download and convert Spotify music to USB and Arduino compatible audio files and then it can't be easier to transfer and play Spotify music on Arduino just like copying and pasting.

Oh, puleeze... that thread was dead for over four years!
Can't say I actually understand what you're trying to suggest either...