Monday, July 18, 2011

Connect your iPhone to the real world

The arrival of Google's Accessory Development Kit (ADK) for Android, which allows you to connect your Android handset to an Arduino-based development board was seen by some as the beginning of the end for Apple's restrictive Made for iPod (MFi) program.

Today we discovered Apple's response to Google's ADK, and while it's still inside a crunchy MFi wrapper, the program is now a bit gooey in the middle, as today saw the release of the Serial Cable for iOS from Redpark.

The cable is a fully MFi approved external accessory that allows home-hobbiests to talk to external hardware, no jailbreak required. On one end of the cable is a dock connector that plugs directly into your iOS device. On the other, is an RS-232 serial port that you can easily connect to anything that speaks a serial protocol.

Suddenly connecting your iPhone to the real world became a lot easier, easier in fact than using Google's ADK.

I've been working with the pre-release version of the cable for a couple of months now and I've put up some sample code to get you started. Including a rather nifty Universal application for the iPhone and iPad which will let you directly control an Arduino board. I've dubbed it the "Paduino."

The "Paduino" application.

Because someone had to...?

 
A simple "Push the Button" example.

Also in the works, but not quite ready yet, is a book which will walk you through how to use the cable and how to integrate your iPhone or iPad into the Internet of Things.

Finally if you're at OSCON next week I'll be talking about the cable and how to use it on Thursday. We're hoping to have an early-release copy of the book ready by then.

I can't wait to see what people can do with this...

19 comments:

  1. Wow, great news! Looking forward to trying it out soon.

    ReplyDelete
  2. Do you think Apple will allow you to use this in the App store? It would be very valuable if Apple would for Educational purposes (o.a. I'm a high school teacher and course designer for teachers).

    ReplyDelete
  3. Can the iPhone/iPad simulators still be used for testing? Any way to pipe arduino serial I/O into the simulator through a macbook's USB port, maybe with a serial/usb converter?

    ReplyDelete
  4. You must be jailbroken for this to work?

    Thanks

    ReplyDelete
  5. No, no jailbreak necessary.

    ReplyDelete
  6. Do I need to get the SDK and compile the xcode myself to try out the paduino app?

    Thanks

    ReplyDelete
  7. how does ios recognize that the redpark cable is attached to the ipod? Does the cable probide true, hardcore serial communications, or it's just a virtual port?

    ReplyDelete
  8. This is amazing, didn't thought that to manage iPhone can be so easier in the real world. Loved your concept to which I will be implementing soon. This would be a new addition to iPhone development.

    ReplyDelete
  9. Hi, I am using the redpark cable to connect an iPod touch device to an mbed controller. I am in total sending 2 values to the controller from iPod. These values are both '1's.These values correspond to 2 buttons present on 2 different views.My problem is, I am able to send my first vale to the controller, but I am not able to send my second button value, which is on a different view. I guess I need to break the cable session after I send my first button value and re-establish it before pressing the second button. Can any body tell me how to break redpark cable session and re-establish it?

    ReplyDelete
    Replies
    1. Ankith, Nope. The way you should do this is instantiate a separate model object to manage the connection to the mbed board via the cable. This model object then offers its own method to send bytes down the cable, and its own delegate protocol which both of the views implement for notifications of bytes coming back from the cable. This is an almost classic MVC pattern at that point.

      Delete
    2. Thank you Alasdair, I will try doing that.

      Delete
    3. Dear Alasdair,

      I am developing an iOS application consisting of two views, if i enter one view and send data to micro controller I'm able to send data but if I leave that view and enter same view or any other view I am not able to send data to micro controller. I hope the problem is new session has to be established each time I enter the view. I tried with the following line of code in view did load

      rscMgr =[[RscMgr alloc] init];
      [rscMgr setDelegate:self];
      [self cableConnected:nil];
      [rscMgr setbaud:9600];
      [rscMgr open];

      with above code as soon as I press app icon ,it terminate the app.

      Could you please suggest how to overcome this issue.

      Cheers,

      Ravi

      Delete
    4. See above. You need to instantiate a separate model object to manage the connection the cable. This model object then offers its own method to send bytes down the cable, and its own delegate protocol which both of the views implement for notifications of bytes coming back from the cable. This is an almost classic MVC pattern at that point.

      Delete
    5. thanks for your reply, i have been following this thread, I am relatively new to iOS and OOP, takes me a while to get my head around it, can you please explain in simpler terms what/how to instansiate a model object.

      Delete
  10. Hello,
    I downloaded and got your app working great the first time I ran it, but after removing the cable from the iPhone and then reconnecting, it did not recognize, because the cable no longer shows up in the Settings -> General -> About Section. Please let me know what i can do to fix this!

    ReplyDelete
    Replies
    1. Do you have a slightly older model TTL Cable? Try disconnecting the cable, then powering the Arduino OFF and then ON, and then reconnecting the cable. If this works then you have a cable with the older pull down resistors which has some problems talking to the 5V Arduinos. You should contact Redpark directly to get it exchanged (at no charge).

      Delete
    2. Its a newly purchased cable, but it was actually the GND jumper inside the TTL end that was not connecting properly so now its working!

      Now that I got your example program working I wanted to see if I could implement the Redpark SDK in Monotouch (all of my iOS development so far has been using Monotouch since my background is mostly C++/C# based programming, as I'm slowing learning Objective-C).

      I bought your book on this subject and I am going through Chapter 2's iPhone Serial console project. I used an existing binding found here (https://github.com/ericc59/monotouch-redpark), and everything has been going smoothly (I was able to get the cableConnected and and cableDisconnected delegate callbacks working well) up until trying to read and write. When I attempt to either read:

      int bytesRead = [rscMgr read:rxBuffer Length:numBytes];
      My version-> int bytesRead = rscMgr.Read (rxbuffer, length);

      or write:

      int bytesWritten = [rscMgr write:txBuffer Length:bytesToWrite];
      MY version-> int bytesWritten = rscMgr.Write(txbuffer,bytesToWrite);

      the program crashes with a SIGSEGV at those lines. I was just wondering (without asking you to debug my code) if you could shed some light on what might be the problem with your experience (i.e. the Serial port actually did not get opened, I could be using the wrong data type for "rxbuffer", etc.) Any of your feedback on this would be greatly appreciated!

      Delete
  11. I’ve recently started a site, the information you offer on this site has helped me greatly. Thanks for all of your time & work.

    Also visit my webpage - 안마
    (jk)

    ReplyDelete
  12. Anonymous6:01 am

    Eleven Space Dev is an agency specializing in website development. We provide businesses with comprehensive web development solutions.

    ReplyDelete