beginner, needs pointers in basic web control

Hi,

I'm new to arduino and ethernet. I bought and ethernet shield some time last year and haven't got around to using it as I wasn't quite clear on how and what I should be using it for! Until now...

I'd like to build a basic HTML web app that can control a DMX device. I should be ok using the DMX simple library, but I'm a bit lost in understanding how my website could talk to my arduino and ethernet shield. I only need to turn things on/off. I've searched home automation but I'm getting a bit lost in specifics. It's probably really obvious, and it's hard for me to search for what I need without understanding the different ways this could work. Be great if anyone could give a nudge in the right direction. Sorry for my ignorance, I'm not really clued up in how internet of things talk and work. thankyou! :~

k

If you have a wiznet w5100 chip based ethernet shield, then simple web control is easy. If you bought an ethernet shield with the other less expensive chip, best throw it in the parts box and get the wiznet chip shield.

Sorry for my ignorance, I'm not really clued up in how internet of things talk and work.

You've got a web browser, don't you? You enter a URL that defines some server to talk to, and some page on that server that is of interest. Hit the enter key, or the Go button, and the browser creates a GET request for that page. The server processes the request, and returns the page.

The Arduino with ethernet shield can play the role of either the browser, making GET requests, or that of the server, responding to GET requests.

If the page that you request is a form, with a submit button, there is a submit action defined for the form. That action defines where to send the page to for further processing. Where is generally back to the same server that served up the form in the first place, though not always. Along with the original server and page information, there are additional fields defined that contain the data from the form fields.

The Arduino as server would be able to tell the difference between a request for the (empty) form and that form being submitted back for processing, due to the extra information supplied.

You'll need to read up on client/server processing, to get a handle on how a browser talks to a server.

You'll need to read up on forms processing, to learn how to define a form, how to place fields and other widgets on that form, and how to define the submit action.

You'll need to look at example code for the Arduino as server, to learn how to parse the returned form, presumably to extract data for the DMX library to process.

thanks Paul, I'll take a look. Pachube appears that it hides a lot of the complexity from having a quick browse. Thanks for outlining the basics.

has a lot of the stuff you need... whether you bought W5100 (best!) or ENC28-whatisit (works)

Pachube: Their own worst enemy! For a simple idea, their website and limitations on free accounts are disappointing. Guide...

What do people who've used both think about "ThingSpeak"?

My initial impressions: The website is as opaque as Pachube's, but they seem to better understand that supporting a bunch of people with free accounts will help them more than being too greedy too early.

My initial impressions: The website is as opaque as Pachube's, but they seem to better understand that supporting a bunch of people with free accounts will help them more than being too greedy too early.

What amazes me about people that use pachube and ThingSpeak is that they don't think they need to pay anything. If you want to post data for all the world to see, pay for the privilege. Life gets so much easier when you accept the fact that there is no free lunch.

Pachube seems to be free now. :slight_smile:

http://blog.pachube.com/2011/01/bringing-down-barriers-pachube-service.html

I had a similar issue, struggling to get the data back from the web form. I put together some thoughts on my webpage Arduino Web forms - tutorial and pasted the code before which compiles with Arduino 1.0

#include <SPI.h>
#include <Ethernet.h>
#define MaxHeaderLength 16    //maximum length of http header required


byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };   //physical mac address
byte ip[] = { 
  192, 168, 2, 201 };   // static ip of Arduino
byte gateway[] = { 
  192, 168, 2, 254 };  // gateway address
byte subnet[] = { 
  255, 255, 255, 0 };  //subnet mask
EthernetServer server(80);   //web server port
String HttpHeader = String(MaxHeaderLength); 


void setup(){
  //enable serial monitor
  Serial.begin(9600);
  //start Ethernet
  Ethernet.begin(mac, ip, gateway, subnet);
  //initialize variable
  HttpHeader="";

}

void loop(){
  // Create a client connection
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        //read MaxHeaderLength number of characters in the HTTP header
        //discard the rest until \n
        if (HttpHeader.length() < MaxHeaderLength)
        {
          //store characters to string
          HttpHeader = HttpHeader + c; 
        }
        //if HTTP request has ended
        if (c == '\n') { 
          // show the string on the monitor
          Serial.println(HttpHeader);
          // start of web page
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("<html><head></head><body>");
          client.println();
          client.print("<form method=get>");
          client.print("<input type='radio' name=r value='1'> One
");
          client.print("<input type='radio' name=r value='2' checked> Two
");
          client.print("<input type='radio' name=r value='3'> Three
");
          client.print("<input type=submit value=submit></form>");
          client.print("</body></html>");
          //clearing string for next read
          HttpHeader="";
          //stopping client
          client.stop();
        }
      }
    }
  }
}