[for everyone who is continuing to read this, it probably won't work anymore and it isn't too reliable in general. I would suggest a better method like this : http://blog.datasingularity.com/?p=148. It works for botnets right? ]
Well, this is the culmination of a lot of posts I have been writing. I devised a simple way to get HTML form data, or URL encoded CGI data, to the Arduino using a remote server. Here is the package to download. Here is a flow chart of how the system works:

form = cgi.FieldStorage()
message = form.getvalue('message')
pipe = open("./cgififo", 'w')
pipe.write(str(message))
pipe.close()
I got this fifo idea from this post. All you do is use the *nix command ‘mkfifo’ and it creates a fifo in the file-system. I used this to communicate between the CGI script and the socket server processes. To get an idea of how to get this section to run, read my post on python CGI linked above. Now to the socket server. This is basically a work in progress but I think it is good enough for right now. I encountered a lot of weird problems that caused me to write some irresponsible code but it isn’t exactly meant to be used without modification so no problem. It simply waits for a client then continually checks the fifo and passes the information off to the client. The client comes in 2 flavors. First is a bare command line interface and the second has a tkinter GUI and is multi-threaded. The problem with the bare single threaded version is that it doesn’t inform the server when the socket is disconnected. The GUI version may or may not work for you. I built a mac app in the dist folder on my intel based MacBook Pro. You can rebuild it on your machine. To get this socket stuff working, look at my post on python sockets. Now for the serial side.
Inside the socket client thread is a pySerial instance. It works exactly the same as my post on sending strings to the Arduino. It waits for the socket to get a string, sends the header to the Arduino, sends the string, then sends another header. The Arduino program is exactly the same as it is on that post as well. You should configure the program to do whatever it is you want to do with that string.
To use all this software, you have to run them in a certain order. First you give the proper permissions to the cgi script and make the fifo. Call it ‘cgififo’ so you don’t have to change any code. Then you run the socket server on your server. After that, you can run the client on your machine and connect. Here are the definitions for the fields:
For host, choose your domain name [e.g. www.datasingularity.com]. The port number is the port which you have bound your socket server. The serial location is the tty file used to identify your Arduino. Baud rate is the serial baud rate and the header character is your serial header byte. Have your ssh or telnet window open to the socket server process on the remote server. When you hit connect you should see the connection in your server window. When you hit start, it will start the child thread and start listening for data. Quit closes the connection and ‘hopefully’ tells the server that you have disconnected. If not, you will need to restart the server to use again.
In conclusion, this code may be pretty ragged, but the concept is what is important and it should be enough to get you started. You obviously can’t do anything too intense with this. It could be used to do some simple but cool things though such as controlling your house from your cell phone, or feeding your dog or cat over the internet, etc. Once again, please e-mail me if you need help getting it working for your project.
**Update** Here is a demonstration video:

11 comments ↓
[...] here for full [...]
[...] Here’s how to control an Arduino remotely over the internet via HTML forms and/or CGI URL encoding… Link. [...]
[...] yonnage wrote an interesting post today onHere’s a quick excerpt [...]
[...] Here’s how to control an Arduino remotely over the internet via HTML forms and/or CGI URL encoding… Link. [...]
[...] This is kinda cool way to control an LCD hooked up to Ardunino with browsers including your mobile phone. [...]
[...] HTML: how to control an Freeduino or Arudino remotely with HTML forms [...]
[...] sent in his efforts to use Python to provide a web interface for his Aurdino. Python is usually pretty easy to [...]
[...] under: cellphones hacks, misc hacks, robots hacks[Benjamin] sent in his efforts to use Python to provide a web interface for his Aurdino. Python is usually pretty easy to [...]
[...] CMD-c && CMD-v » Control Arduino remotely with HTML forms (tags: arduino network programming python web) [...]
[...] http://blog.datasingularity.com/?p=50 [...]
[...] http://blog.datasingularity.com/?p=50 (control arduino through html) [...]