Interfacing with iPhone

Hey guys,

I've never make an app for an iPhone before, but I have a jailbroken iPhone 3g 3.1.2 and I'd like to learn how.

One of the first ideas that came to mind is to use the iPhone as a display and possibly data input to an arduino. I assume serial communication would be best for this.

Anyone worked on an arduino+iPhone project before? Where should I start?

Or where should I start in general in learning to develop for iPhones?

Thanks, Panici (sent from my cell, sorry if I've made any gramatical errors!)

EDIT: Ideas for the software side on the phone. Most of it over my head, having never developed for the iPhone. http://hcgilje.wordpress.com/2010/02/15/iphone-serial-communication/

Looks like this will take care of physical dock connection. http://www.podgizmo.com/p/118/ipod-iphone-ipad-podbreakout-mini

The iPhone has a 3.3v TTL serial connection on pins 12 and 13 apparently. (Detail here: http://resolvehax.blogspot.com/2010/10/iphone-serial-port.html)

What's the best way to interface this with the Arduino?

There is a book that covers this in a lot of detail. They use a cable that is designed specifically to pull the requisite pins

http://shop.oreilly.com/product/0636920021179.do

Cable:

http://blog.makezine.com/2011/07/18/59-cable-lets-you-connect-iphone-to-arduino-no-jailbreaking/

And if you have to actually build an app for the Iphone to use it, you will need a Mac of some sort. I bought a Mac mini for just this purpose.

use touchOSC. hexler.net/touchosc

more info here: http://dduino.blogspot.com/2012_02_01_archive.html

Sacman: There is a book that covers this in a lot of detail. They use a cable that is designed specifically to pull the requisite pins

And if you have to actually build an app for the Iphone to use it, you will need a Mac of some sort. I bought a Mac mini for just this purpose.

I wanted to avoid buying an expensive cable. That's why I was thinking of using the 3.3v TTL serial out of the iphone.

I'll look into that book. And i've got a 6 year old Macbook Pro (that's still my main computer!).

What are the chances of the Redpark Serial Cable SDK working with a home-built serial interface?

sirbow2: use touchOSC. hexler.net/touchosc

more info here: http://dduino.blogspot.com/2012_02_01_archive.html

Looks like iOSC and touchOSC both use WiFi/ethernet to connect to the Arduino. Certainly a possibility, but Serial seems more reliable to me.

OP,

If you can find how to run a bluetooth serial monitor on an iphone, I promise to handle the rest. Cause the rest is easy :) I use my phi_interfaces library to turn a serial port into a virtual keypad and a character through the serial is equivalent to an actual button press on arduino. But that is android phone, where free bluetooth serial monitors are plentiful. I looked high and low in apple appstore and found none! Wrong phone for DIY and hacking. Android is much easy to get started in my opinion.

The Redpark just gives you a nice clean plug to your iPhone with a D9 connector on the other end. You might very well be able to get away with just cutting the end off the cable that came with the Phone. Since you can use that to interface with a computer, one has to assume that the RX and TX signals are in that cable. In the maker's shed description, it appears that they just connect the D9 to an RS232 convertor.

So in theory, if you can figure out which wires are which coming out of the end of the iPhone plug, you can connect them into a standard FTDI board to transfer data.

I'm sure someone has already done this. I am at work now so have limited Web access to search.

liudr: If you can find how to run a bluetooth serial monitor on an iphone, I promise to handle the rest. Cause the rest is easy :) Wrong phone for DIY and hacking. Android is much easy to get started in my opinion.

I've heard good things about Android and DIY, but where's the fun if it's easy? :)

I think your problem is that you haven't looked at unofficial code, that will only run on a jailbroken device. Check out these links, they look to have some information about bluetooth. Not sure if it's what your after though. http://www.iphoneheat.com/2010/02/ibluenova-hits-the-cydia-store/ http://code.google.com/p/btstack/wiki/GettingStarted

Sacman: The Redpark just gives you a nice clean plug to your iPhone with a D9 connector on the other end. You might very well be able to get away with just cutting the end off the cable that came with the Phone. Since you can use that to interface with a computer, one has to assume that the RX and TX signals are in that cable. In the maker's shed description, it appears that they just connect the D9 to an RS232 convertor.

So in theory, if you can figure out which wires are which coming out of the end of the iPhone plug, you can connect them into a standard FTDI board to transfer data.

I'm sure someone has already done this. I am at work now so have limited Web access to search.

I wish I could just use a regular iPhone cable. There's separate data lines for USB. I'll need a breakout board to get at the serial pins on the iPhone dock connector.

I don't think I can connect directly to an RS232 connector, as the iPhone uses 3.3v TTL, whereas RS232 is +5v.

Would it be possible to connect through this (http://www.sparkfun.com/products/8745) directly to an Arduino's TX/RX lines?

Why can't I just use a simple resistive voltage divider with 1.5k? + 3k? in series, take the output across the 3k resistor to get 3.3v?

That would be used on the TX line of the 5v device. Is it because the +3.3v on the other device's TX isn't a strong enough logic high for the +5v device's RX?

Panici,

Thanks for the info. I have not thought about freeing iOS before. Great idea! What I was looking for is serial port on top of bluetooth hardware.

This is what I use on my android:

http://www.sena.com/download/manual_bterm/overview.html

It is simply a terminal that establishes serial port connection to another bluetooth device. If you can find such a terminal program, you can easily control or sense with arduino wirelessly with this bluetooth bee for arduino. I have one with a shield for it:

http://iteadstudio.com/store/index.php?main_page=product_info&cPath=7&products_id=350

+

http://iteadstudio.com/store/index.php?main_page=product_info&cPath=18&products_id=348

Or, just use the iPhone's browser and an Ethernet or WiFi card on the Arduino.

That way no iOS programming, just HTML programming.

Just FYI,

You must be an Apple MFI (Made for IPod) partner to talk regular (non-BLE) Bluetooth from the iPhone. Assuming you can do that (and its not easy), you then need to incorporate a small microchip sold exclusively to MFI members from a manufacturer in China into your design. Then you can get the full Bluetooth libraries from your Bluetooth chip supplier (Real Networks has them), but again you must be an MFI partner to get the libraries too.

In short, you can do it, but its really not for hobbyists.

That being said...iOS 5 does allow anyone to talk to BLE (Bluetooth 4.0 Low Energy) Bluetooth chips, but those are pricey and the API is limited. Also, Bluetooth LE support is only available with the latest iPhone 4S.

-Mitch

[quote author=Mitchell Christensen link=topic=91789.msg690784#msg690784 date=1329241619] Just FYI,

You must be an Apple MFI (Made for IPod) partner to talk regular (non-BLE) Bluetooth from the iPhone. Assuming you can do that (and its not easy), you then need to incorporate a small microchip sold exclusively to MFI members from a manufacturer in China into your design. Then you can get the full Bluetooth libraries from your Bluetooth chip supplier (Real Networks has them), but again you must be an MFI partner to get the libraries too.

In short, you can do it, but its really not for hobbyists.

That being said...iOS 5 does allow anyone to talk to BLE (Bluetooth 4.0 Low Energy) Bluetooth chips, but those are pricey and the API is limited. Also, Bluetooth LE support is only available with the latest iPhone 4S.

-Mitch [/quote]

Mitch,

You said what I couldn't (didn't know this level of detail). As a DIYer, I hate my ipad.

It does sound like this is at least one area where Android blows iPhone away. I don't want to open that can of worms. I have an iPhone and I love it.

I have built a few apps on that run on the simulator but have never sucked it up and paid for the developers license ($99). I have also made no effort to connect to the Arduino although this may be something I look into in the future. The project that I have in mind would couple a GPS unit with the canned iOS mapkit which is really nice and it will be perfectly fine if the iPad is cabled to a 'backpack'.

As far as the question about that Sparkfun level convertor, I remember when that hit their new products post a few weeks ago and wondered where it might be useful to me but I am pretty much trying to keep everything at a 3.3 level. So my question would be, if the iPhone already communicates at a 3.3v logic level, the Atmel chips will work at 3.3v. So maybe you could build an breadboard Arduino to run at 3.3v then there is no need for level convertors at all. You can also pull the chip from your Arduino and run some wires and still use the Arduino as the programmer to your breadboard.

Keep us posted because I am really curious about how this works out.

Soon enough M$ will do the same to charge developers $$ annual fee and wants their 25% for apps sold at their store. I wonder what google will soon do.

Ah, the thread has gone a little off topic. I wasn't planning to pursue the bluetooth at all.

I've ordered a dock connector breakout board, and i'm going to try a voltage divider to get direct TTL serial communication with an arduino working.

Panici: Why can't I just use a simple resistive voltage divider with 1.5k? + 3k? in series, take the output across the 3k resistor to get 3.3v?

That would be used on the TX line of the 5v device. Is it because the +3.3v on the other device's TX isn't a strong enough logic high for the +5v device's RX?

Pancini,

I don't know the answer to your reposted question but go back to my last post a couple up that way ^^^. I think it is possible that you can bypass the level conversion entirely if you breadboard your Arduino and run it at 3.3v. This sounds theoretically correct but I would have to try it to know for sure and I am certain there are others on here that can poke holes if there are any.

Sacman:
I think it is possible that you can bypass the level conversion entirely if you breadboard your Arduino and run it at 3.3v.
This sounds theoretically correct but I would have to try it to know for sure and I am certain there are others on here that can poke holes if there are any.

That seems like a possibility.

EDIT:
I posted on Sparkfun’s board for a logic level converter:

Panici

Why can’t I just use a simple resistive voltage divider with 1.5k + 3k in series, take the output across the 3k resistor to get 3.3v?

That would be used on the TX line of the 5v device. Is it because the +3.3v on the other device’s TX isn’t a strong enough logic high for the +5v device’s RX?

** MikeGrusin**

Often this will work fine. As you’ve guessed, the real issue is whether the 3.3V TX side’s H and L levels will match up with the H and L thresholds of the 5V RX side. You can often determine this information from both datasheets, see this tutorial for info. http://www.sparkfun.com/tutorials/225

Panici

According to the ATmega328 datasheet, Vih is 0.6Vcc at Supply voltage of 5v.

So Vih in my case is 3v.

I’m probably not going to find a datasheet for an iPhone 3G (my 3.3v device) so i’ll just have to try it and find out!

Thanks for your help :slight_smile: