Internet control via smartphone

Hi everyone!

I am beginning work on a new project and haven't yet played around with hooking the Arduino up to the internet. My end goal is to be able to control my arduino via smartphone. I am not sure where to begin.

There are two ways that I have thought about achieving this:

  • Setting the arduino up on my home network with port forwarding on my router.

  • Having the arduino "listen" for instructions from a web server. This would prevent the mess of port forwarding and a non-static ip address.

The problem with the "listening" method is that the arduino wouldn't receive instructions INSTANTLY (or as near to instant as I can get), which is what I am hoping to achieve.

Does anyone have experience with this? Ideally I would like to be able to have multiple arduinos going at a time, each listening for their own instructions. If anyone can point me in the right direction I would really appreciate it!

Thanks everyone,

Ryan

I wrote something very similar to this earlier in the week.

The big challenge of implementing a web server on all Arduino boards, except the YUN, is you will go to a lot of effort, to end up with a non-standard and pretty rubbish web server. HTTP is an ambiguous protocol and you need a fairly large amount of RAM and Runtime to parse and respond to it properly.

The YUN was designed to bridge the gap between MCs and webservers. The Linux side of the board allows you to run a well tested, standards based web server. For a single board project, it should be the best fit solution. I say 'should' because I have yet to try using a YUN.

For multi-device projects, you might consider dedicating a more powerful Linux board to running the webserver, like a Raspberry Pi or Beaglebone Black, in a hub and spoke topology. The webserver would be the hun and the Arduinos make up the spokes. The downside is having to learn to use a second development environment.

In either case, the architecture is the same. Let Linux look after the web serving and then have a much simpler, light weight protocol controlling the Arduino/s.

Thank you for the response! I forgot to mention that I ordered a WiFi shield from Adafruit. It seems this has the ability to both receive and send data and act as a server? I admit that I'm a complete beginner and don't completely understand this yet, but maybe the shield that I ordered will allow me to do exactly what I'm trying to? If you look on Adafruit.com for the CC3000 you will find the part that I purchased.

If I'm understanding your response correctly you are suggesting using a raspberry pi as an intermediary between the smartphone/internet control method and the arduinos? This sounds like it will work, I'm just confused as to how the arduino knows when something changes on the server? The only way that I can think to make this work would be having the arduino continuously check the server for updates? This doesn't seem like an efficient way of doing things, but maybe it's normal? I guess I'm not understanding how the server can send a message directly to the arduino without knowing it's specific address?

My project really only involves one arduino, that needs to be controlled at a time. I just would want the ability to have multiple devices listening for their own set of instructions. For example, I might have three individual LED's powered by Arduinos that are controllable via the internet (lets say I want to turn a light on that is in Chicago and I am in Cleveland at the moment).

Any further insight into what I might need to do (resources, tutorials, etc.) would be awesome!

Thanks again for your help,

Ryan

If you want to the web browser on your smart phone to control things via an arduino, then that can be from simple to very detailed. the below discussions might have some useful info. If you search the forum for "smart phone" and "android", you should get a lot of similar discussions and projects.

http://forum.arduino.cc//index.php?topic=140740.0

http://forum.arduino.cc//index.php?topic=127770.0

MattS-UK: For multi-device projects, you might consider dedicating a more powerful Linux board to running the webserver, like a Raspberry Pi or Beaglebone Black, in a hub and spoke topology. The webserver would be the hub and the Arduinos make up the spokes. The downside is having to learn to use a second development environment.

In either case, the architecture is the same. Let Linux look after the web serving and then have a much simpler, light weight protocol controlling the Arduino/s.

MattS-UK,

You've just described the Raspberry Pi-based RFXduino TCP/IP gateway system perfectly. :-)

The other advantage of this approach, besides being more powerful (e.g., https access, courtesy of Linux), and making the programming on the client (i.e., Arduino) side simpler, is that for multi-device projects (e.g., typical home automation), it works out signficantly cheaper. Like between $17 and $25 total hardware outlay for each additional client (a basic Uno-class dev board plus either a low power or a high power radio module), if you are willing to do some soldering yourself. Compare that to the price of a Arduino+WiFi shield, or a Yun...

So yes, couldn't agree with you more! ;-)

RyanWorcester: If I'm understanding your response correctly you are suggesting using a raspberry pi as an intermediary between the smartphone/internet control method and the arduinos? This sounds like it will work, I'm just confused as to how the arduino knows when something changes on the server? The only way that I can think to make this work would be having the arduino continuously check the server for updates? This doesn't seem like an efficient way of doing things, but maybe it's normal? I guess I'm not understanding how the server can send a message directly to the arduino without knowing it's specific address?

Well, I can tell you how I do with the RFXduino gateway.

There are two basic approaches to achieve this actually; one where a central web server runs on Raspberry Pi, and the user connects to that from the outside. Interacting with the web server (clicking links, etc.) sends messages via TCP/IP to each Arduino client (there is a unique TCP/IP:port no assigned by the gateway to each Arduino client). Conversely, the Ardunos send update information when appropriate to the server to be aggregated into a unified presentation by the web server for the multiple devices. I think this is essentially the same idea as the approach MattS-UK was proposing.

The other way to approach it in RFXduino is to have each Arduino run it's own individual web server, just as if it had an Ethernet Shield or WiFi shield, and the gateway simply passes through web browser connection requests to each Arduino on demand. This is straightforward since each Arduino has a unique TCP/IP port number... you just point your web browser directly to the relevant port for the Arduino you wish to connect to.

And many variations besides. Lots of ways to skin the cat when dealing with standard TCP/IP connections between devices.