Go Down

Topic: Connecting Arduino to iPhone/iPod serial (Read 37022 times) previous topic - next topic


Jul 15, 2010, 07:27 am Last Edit: Jul 15, 2010, 07:33 am by ckrames1234 Reason: 1
To interface an an arduino with an iPhone, its really quite simple. First, you need to hook up the TX/RX pins from a dock connector (pins 12/13 respectively) with the RX/TX pins on the Arduino (pins 0/1 respectively). You also need to connect the GND wires (Pin 1 on dock connector).

Please note that i have NOT TRIED THIS yet, and have not measured the voltage that the iDevice uses to send/receive data. if you were to do this you would need to measure the voltage, and make sure it matches before proceeding, or risk damaging one of the devices. I am pretty sure (from reading other sites) that the iPhone uses 3.3V for its data, so a 1K resistor will work just fine in between Arduino TX and iPhone RX.

As for software side on the iPhone, it would need to be jailbroken, as there is no API for direct serial communication over USB within the SDK. Once jailbroken you can use the UART interface for the dock connector, which is /dev/tty.iap, so basically any executable on the device can interface with the arduino easily.


I set it all up and got no results.

I did the following:

1. Jailbroke my iPod touch
2. Installed cmd line app to monitor serial comm on the iPod (forget the name now)
3. Connected the tx->rx and vice-versa.
4. Dropped the Arduino voltage down to something the iPod touch could handle (3.3v)
5. Wrote my sketch to spit out serial comm from the Arduino to be read by the iPhone.

Everything appeared to be set up right. Programs ran, no smoke appeared, but nothing showed up on the iPod touch side.

I would be VERY interested to see if anyone has managed to get serial traffic from the Arduino to an iPhone, and what they code looks like. Right now I'm at a total loss for what I am doing wrong (assuming its possible), and I don't even know where to begin trouble shooting since it could be anything at this point.

So does anyone know of a project that has managed this? No Wireless, no 3rd party protocals, no standard play/pause commands, but true serial communication TO the iPod Touch.


Just using a 1K resistor won't step the voltage down to 3v3, you'd need a level shifter or voltage divider on the IO pins and to use 3v3 out on the arduino (if yours has it) for the Vcc.


I used a voltage divider and triple checked it because I don't care to buy a new iPod touch right now ;-)

I don't have the hardware to intercept the arduino tx line and see if there is anything coming out...
This is why I'd love to find someone who has pulled it off. First, it'd show me that it's actually possible, and second, if they shared any piece of their project I could duplicate it on my own and see if it's my hardware that's bad, my code, or my design.


Well, some guy did it successfully here:
Although, it is a bit outdated.

Many things could have gone wrong with your setup, but i think it might be the software you installed on your iTouch (maybe improperly configured?). (BTW you can see if the arduino is transmitting data by checking the TX LED on the device)

When my PodBreakout board gets here (It just shipped) I will develop an iphone app to read the serial port (I have a mac cocoa app that does so currently, so the principle is the same) and open-source it.


Aha, I just got it to work with my PodBreakout v1.4, because the 1.4 version of the board had a manufacturing mistake which led to all the odd/even pins being reversed  >:(.

http://www.kineteka.com/PodBreakout-v1.aspx (Read to the bottom of the page)

But now it works fully with my arduino using minicom from Cydia :D


Son of a.... I have the 1.4 breakout, and I was not aware of the manufacturing error. 30 seconds with a soldering iron and I had my iod touch screaming "Hello World!" that was produced by the arduino! Conrad, I could almost kiss you  ;D

Now to figure out how to get at that serial input from ObjectiveC code running on the touch... If you decide to open source that part of your project, I'd be very interested in it. I've never done any sort of port communication in ObjectiveC...or any language for that matter   :-/


Yeah, I didn't exactly find that myself, some guy on irc.saurik.com did. I'll try getting an app to read the the serial working and then ill put it up on http://svn.kramerapps.com so everyone can join in the fun.


That would be awesome.  I'll probably work on it too since my project is an educational endeavor. Still, an iPod touch display screen falls into the feature creep category of my project :)


Okay, i wrote an objc serial interface class for the iap tx/rx ports on iPhone. Simply create the object, set a delegate, and tell it to start reading at a specific baud rate. I didnt test the close methods (Im too lazy) but they should work just fine. I did take some code from a certain 'Arduino Serial Example' by Gabe Ghearing. Whats super awesome about this class is that it works in the sandbox so it doesnt necessarily require a jailbreak (just a dev account).




So you've managed proper serial communication without jail-breaking?? !!


Technically yes, but such app would not be accepted into the app store as it does not use Apple's IAP protocol and the matching 'Made for iPhone' trademark. Approvals for those things must be thoroughly reviewed by Apple. The reason this way works is because /dev/tty.iap has crwrwrw permissions with the owner of root (and crwrwrw means the userland user, mobile, can access the port).


I wanted to chip in that I put Conrad's code onto my iPod Touch (OS 4.1) and so far no joy.

The call to open(bsdPath, O_RDWR | O_NOCTTY | O_NONBLOCK ) return -1

Perhaps I need to jailbreak the device after all...


Nov 04, 2010, 05:16 am Last Edit: Nov 04, 2010, 05:17 am by chrisionetworks Reason: 1
The other thing to remember is that the iPhone/iPod/iPad serial port is working at TTL levels - the best way to do this if you want true serial communication is to run this through a TTL/RS232 converter like a MAX3232 chip which will prevent you from toasting your iDevice.

I built a serial port for my iPhone that I've been using this week to console into Cisco routers and it's working great.  Jailbroken, but only because I just want to use minicom from the CLI, as writing an app to do so adds no value for me.

Conrad nailed it with the acceptability for the appstore.  But, then again, I think people who want this will probably want jailbroken phones to begin with.



I dunno. It didn't work. I jail broke the phone. Then it worked. I feel like at least with my 4.1 iPod Touch I *had* to jail break it to open /dev/tty.iap successfully.

Go Up