I am thinking of controlling an Arduino over the Internet.
Say I don't have a static IP connection to my Arduino (I am using a GPRS shield.) In such situations I have to follow a procedure something like this. Suppose I am trying to on/off a single device through web.
There is a web site with a domain name hosted on a server. There is a PHP web page and an associated MySQL table to hold ON/OFF commands.
When a user needs to turn on the device he sends a specific request to PHP page. It changes a flag stored in a table in database.
The arduino sends requests periodically to web page to ask whether there is any update. The PHP page checks the database and respond to arduino so now the arduino can turn on/off the device accordingly.
My Questions are,
Running a (web) server in Arduino might be another approach. But can I access it from public internet? I am using a GPRS module. Does the mobile service subscribers allow incoming connections?
To get a realtime output I have to send requests continuously with a very short dalay. And the PHP page has to query the database again and again. Performance wise this is not a good approach. What are the alternatives I have in this case? (I am using a database since I am planning to have many users with many devices.)
What are the alternate approaches I have to implement the same?
Interesting project. I would be concerned about the cost number you get when you add up the polling traffic over GPRS.
The main alternatives to a polling approach involve persistent connections that are mostly idle. A websocket client for Arduino would be one approach. There is code out there, if you search.
Another approach would be to put a Redis server in the middle of the architecture and use it to distribute commands. I mention this because I've experimented with the architecture a bit and I've posted code here for a Redis client that would happily sit and wait for commands without keeping the link too busy:
Your arduino fleet would connect up to the common-visibility Redis server; it's the only fixed address you need. Then you might have a web program in PHP or whatever, using the Redis adapter to issue commands through the Redis subscription fabric.