Go Down

Topic: connecting to the Arduino server using its IP with android (Read 308 times) previous topic - next topic

HI, I would really thankful  if someone could help me regarding  IP connectivity .
Lets sat that there is an arduino web server using the Ethernet shield and a web page which switching on/off a LED with its IP ( . so when I enter this IP in  a browser I could see the page and control the LED. Now lets say I wana turn this web page to an android App using PhoneGap.
What code should I use at the top of the HTML code so  the app connects to the arduino IP automatically when it is started ? in other word do the same thing as entering the IP in the browser?
I've tried :

socket = new Socket("", [80]);

but its not working.
THANKS in advance.


If you are using the Droid's cellular provider for the data connection, you can't use a 192.168.x.x ip. Those are localnet ips.

You basically have two choices:
1) Port forward a port on your public ip (WAN interface on the router) to the port on your Arduino and use the public ip:port.
2) Connect to the same router's wifi and use it for the data connection using the 192.168.x.x ip.

That works with my CrackBerry.

Thanks a lot for your response,
actually I am trying to do the 2nd solution that you've  provided here but i dont know the coding. i may not explained it well.
I convert the web page to an App, then as the phone is connected to the router through a Wifi i wana use a code that when i start the app it automatically connects to the shield as the shield is also connected to the same router and is waiting for a client.
in the Head part of the HTML coding of the web page which i am going to convert it to an android app, what code should i use ?
something like :

socket = new Socket("", [80]);




Then you have already gotten the http connection to the Arduino working with your Android? If not, work on that first. Otherwise you could end up chasing your tail. On your Droid web browser:

Go Up