best way to communicate with a server?

Hi all,

Id like to try and investiate how I can use relays in my house to switch on some lights.

So ive borrowed my friends arduino and ethershield so I now have 2 arduino decimilia's and two shields to play with

I would like to use a webserver as the GUI to the two devices, Can anyone suggest a method I can use to link the two devices via the ethershield to the server.

Basically I would like to use my iphone to switch on two seperate lights via a web server. Does anyone have any recommendations on how to go about doing this?

I am thinking the best way to go is to get the two devices to look at the state of a database or a text file to see if they need to switch on or off, Im not sure if that is the best choice given that if they need to do a lookup ever second that will be a lot of traffic!

Would PHP or Python be able to do some kind of push notification to send a signal out to the two Arduinos?

Thanks Mathew

Your best bet would be the way you describe. Poll a PHP or PERL script every second that would respond with the state of a database. This is actually very minimal traffic. Almost every interactive website does this with AJAX.... gmail, facebook, twitter, etc. And most of those sites are doing it at more then 1 second intervals with several different processes at a time.

ok cool,

and the best way to issue a PHP request would be something like a HTTP request with details like deviceID embedded to see what state it needs to be in?

These are at the moment incredibly expensive light switches, would there be another way to communicate with the server? like a wireless multicast? So I could use the arduino pros and leave them embedded somewhere? Thanks Mathew

I suggest you run a web server on your arduino. Send GET request to the server to either control a light, or get the status of a light. Make a simple html page to send the request. The arduino evaluates the request, performs the request, and sets an internal status variable for the light. Another GET request would request the status of the light, at which time the arduino would return the internal status variable.

look at pachube com (this is my first post so it doesn't let me put the dot in) it's open source and let's you do input and outputs - look on the tutorials. They also have some arduino code. I've only used it for output where I send data to the pachube server.

pachube is awesome, and is made for exactly what you are doing.