Inspired in part by a recent discussion with some fellow makers about getting the iPhone to talk to stuff, I built a sample iPhone app using PhoneGap that lets you tell an Arduino to take a given pin high or low. It’s pretty basic: in the iPhone app, you type in the IP address and pin number, and click an ON/OFF button (the button has no clue about the current state of the pin yet). You could probably adapt this to work with the Arduino using other network modules, like the MatchPort.
- The Arduino needs an Ethernet Shield, and needs to be connected to an Ethernet LAN. There’s a sketch you need to install to get it to work.
- The iPhone needs to be on a Wi-Fi network (must be on the same subnet as the Ethernet LAN), and you’ll need to be a registered iPhone developer to compile and install this on your own phone.
I’ve posted the source here, and I think everything is explained in the README. Because it’s based on PhoneGap, you could just double-click on index.html and test it in Safari or some other WebKit browser.
I said inspired in part above; the other part of the inspiration came from editing Jonathan Stark’s excellent upcoming Building iPhone Apps with HTML, CSS, and JavaScript, which is available for preorder now.
Hi,
Very interesting. Have you developped something since this sample iPhone (Wi-Fi) to Arduino (Ethernet) app ?
Do you know if it’s possible, with phonegap and in wifi, to use the iphone to change data or process in the arduino through wifi ?
For example, prepare a sequence on the iphone, send the sequence to the arduino, tell the arduino to start the sequence, ask from the iphone to the arduino where the arduino is in the sequence… and lots of tings like that…
Thanks.
I haven’t done anything more since writing this example.
I think you could accomplish what you describe. You’d need to decide how you want the two to communicate and use that communication method to send the messages between the devices. I use XmlHttpRequest in my application, and that’s a fairly simple way to do it.
Hello
Is there anyone who has messed with the XBee module? I have just invested in one and wish I could put it up to be able to talk with an iPhone without needing a computer . I’ve made a few experiments with Arduino and Processing, but then I run it through a PC and I would rather not.
initially, I could just press my iphone and turn on an LED.
is there anyone who has experience in the field or fiddling with it like me?
Sincerely,
Carsten
carstenjelkjaer@gmail.com
is there any reason that this sketch would not work from an external network if i had port forwarding setup on my home router ?
Hi stefan,
That should work fine. There may be something else interfering with the connection, however. I’d suggest trying to connect directly from the iPhone browser to a URL like http://YOUR_EXTERNAL_IP_ADDRESS/web/PIN_HIGH?p=1 to make sure that port forwarding is 1) configured correctly and 2) not being blocked somewhere between the phone and your router.
Thanks for the great example, ordering the Ethernet shield now !
Do you have any experience getting the Ethernet shield to serve current sensor data to the web? If not, could you point me toward so info ?
I don’t have any info specifically on that, but I bet you can find some cool stuff at the Arduino playground: http://www.arduino.cc/playground/