Pages: [1] 2   Go Down
Author Topic: iphone + arduino + wifi shield  (Read 1392 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hello
1.I want to use iphone to control arduino with servo motor, how to communicate between iphone and arduino?
2.there is a example in arduino called web server (in ethernet shield ),what difference between this method(like send the "http://192.168.1.177/@your angel"to arduino) with TCP protocol?which is better?
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 180
Posts: 8103
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

HTTP uses the TCP protocol.  The advantage of HTTP is that you can use a web browser as a client and don't have to write your own client software.  Do you want to write an iPhone app to talk to your Arduino or do you want to use the Safari web browser already on the iPhone?
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Central MN, USA
Online Online
Tesla Member
***
Karma: 65
Posts: 6932
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I would take John's recommendation and use HTTP. As he said, you can use web browser instead of writing an app. It's cross-platform in case you want other devices to access your arduino. Plus, all the user interface is done by browser so you don't have to do any.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

HTTP uses the TCP protocol.  The advantage of HTTP is that you can use a web browser as a client and don't have to write your own client software.  Do you want to write an iPhone app to talk to your Arduino or do you want to use the Safari web browser already on the iPhone?
No, I dont want use web browser. I want write UI in Xcode, Arduino just receives data.So I am wondering how to build the communication. And there are protocols I know such as TCP, OSC...but I dont know how to build that. Is there any tutorail?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would take John's recommendation and use HTTP. As he said, you can use web browser instead of writing an app. It's cross-platform in case you want other devices to access your arduino. Plus, all the user interface is done by browser so you don't have to do any.
I agree with you, I need to build the interface in Xcode. Is there any easy way to do that? Now, the massage I am sending is like "http://192.168.1.177/@yourAngelData" is
there any good way just sending "servoMotorNum_yourAngelData;servoMotorNum_yourAngelData"like this?or is there any other way better than mine?
Logged

Central MN, USA
Online Online
Tesla Member
***
Karma: 65
Posts: 6932
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What is your background in objective-C and programming in general? I don't know of tutorials (must exist online somewhere) but you can take free iTunes U courses to learn how to program in iOS. I'd not waste my time learning it since that only covers part of the mobile devices. Sorry, no more helpful info from me. I'd be interested in seeing a quick tutorial myself just to see if I can quickly handle it (say a day's work).
Logged


Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 180
Posts: 8103
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I need to build the interface in Xcode. Is there any easy way to do that? Now, the massage I am sending is like "http://192.168.1.177/@yourAngelData" is there any good way just sending "servoMotorNum_yourAngelData;servoMotorNum_yourAngelData" like this?or is there any other way better than mine?

TCP will send a stream of bytes, sort of like Serial, but with the advantage that bytes never get lost.  You get to decide what you want to do with that stream of bytes.  You can send your data in binary, which is efficient, or you can send the data as text and add framing characters to make it easy to parse.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What is your background in objective-C and programming in general? I don't know of tutorials (must exist online somewhere) but you can take free iTunes U courses to learn how to program in iOS. I'd not waste my time learning it since that only covers part of the mobile devices. Sorry, no more helpful info from me. I'd be interested in seeing a quick tutorial myself just to see if I can quickly handle it (say a day's work).
thanks anyway~~
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I need to build the interface in Xcode. Is there any easy way to do that? Now, the massage I am sending is like "http://192.168.1.177/@yourAngelData" is there any good way just sending "servoMotorNum_yourAngelData;servoMotorNum_yourAngelData" like this?or is there any other way better than mine?

TCP will send a stream of bytes, sort of like Serial, but with the advantage that bytes never get lost.  You get to decide what you want to do with that stream of bytes.  You can send your data in binary, which is efficient, or you can send the data as text and add framing characters to make it easy to parse.
I c ...thanks a lot.  how do you think the OSC protocal? Is better than TCP in this case?
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 180
Posts: 8103
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

how do you think the OSC protocal? Is better than TCP in this case?

I am not familiar with the OSC protocol. If it works over WiFi then, like HTTP, it is probably layered over TCP (or UDP). If it will work for your purposes and will save you the trouble of defining your own protocol then, by all means, use it.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Southern California
Offline Offline
God Member
*****
Karma: 5
Posts: 539
I like blinky lights
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I c ...thanks a lot.  how do you think the OSC protocal? Is better than TCP in this case?

It looks like it's an older protocol - Wikipedia says its data wrapped in SLIP wrapped in UDP... I haven't seen SLIP since about 1998....

My $0.02 is: I sure it's a fine protocol if you're already doing MIDI-ish things and can find libraries that you like, go for it. If not, then there's no way it would be worth your time to write your parser for it. It would be orders of magnitude simpler to do something like make the Arduino be a basic web server and interpret URLs e.g. "http://192.168.1.109/?servo=2&angle=135" and have the client issue plain old HTTP requests.
Logged

http://en.wiktionary.org/wiki/magagna <-- My last name.  Pretty apt.

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I want to do the same thing... use my iphone to control a servo using an arduino. However I was looking at trying to do it using HTTP or a telnet server. Which one do you think will work better. I have test programs of each method but there are bugs in them and so they don't work. Any Advice?
Logged

Central MN, USA
Online Online
Tesla Member
***
Karma: 65
Posts: 6932
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I have test programs of each method but there are bugs in them and so they don't work. Any Advice?


On the advice side, read sticky post. You need to post the codes, and where they come from, what hardware they assume, what hardware you have. What the intended effect of the code is and what actual effect/error messages you observe. You lack above basics on a tech forum.
Logged


Southern California
Offline Offline
God Member
*****
Karma: 5
Posts: 539
I like blinky lights
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I want to do the same thing... use my iphone to control a servo using an arduino. However I was looking at trying to do it using HTTP or a telnet server. Which one do you think will work better. I have test programs of each method but there are bugs in them and so they don't work. Any Advice?


Well..."better" really depends.

Telnet is a simpler protocol to code for the server, since you don't have the overhead of HTTP headers etc. It's basically the same as using the Arduino IDE serial monitor. On the other hand telnet is more difficult to support on your client end (an iPhone) because it's not native and you'll have to do everything with typing on a tiny virtual keyboard.

HTTP is more work on the server side because there's more parsing to do, but it's nicer on the iPhone side because the client is built in (Safari) and you can easily make a UI with buttons and sliders etc. out of HTML elements, no custom client coding required.

As far as debugging advice -- I'd separate the communication code from the action code and make sure the two pieces work. For example, get the servo working how you want via the serial monitor. Next, get the communication between the iphone and Arduino working, again using the serial monitor to verify (e.g. click a form on your iPhone, have the Arduino serial print out "I saw the form click!", etc.). Then combine and enjoy.

Good luck!
Logged

http://en.wiktionary.org/wiki/magagna <-- My last name.  Pretty apt.

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

how do you think the OSC protocal? Is better than TCP in this case?

I am not familiar with the OSC protocol. If it works over WiFi then, like HTTP, it is probably layered over TCP (or UDP). If it will work for your purposes and will save you the trouble of defining your own protocol then, by all means, use it.
thanks a lot !!!!!!
Logged

Pages: [1] 2   Go Up
Jump to: