Controlling Arduino via Web

1.- I've read the the Ethernet Shield is capable of creating a web server and connecting it to the internet. How? I mean, whats the configuration you need to do to make that possible? the Arduino would need at least an IP address.

The shield needs an IP address, a MAC address, and possibly a subnet mask. The IP address is how other devices find the Arduino with shield. The MAC address must be unique on the network. Newer Ethernet shields come with a MAC address that you should use.

2.- If connected to the internet, to what IP address or domain name will the clients go to in their browsers? Let's say I develop a web page capable of monitoring some offices in a building, and the page is capable of turning off and on the lights in said offices. If I'm the floor administrator, to what page I must go to in my browser?

http://arduinoIPAddress/SomePageThatArduinoServes.htm

Note that the IP address must be publicly accessible. Depending on the network that the Arduino connects to, this may or may not be easy to ensure.

3.- If it is indeed possible to make a web server to host a page, can I design that page in PHP/HTML?

HTML, yes. PHP, no. PHP does not run on the Arduino.

Can I for example, download and edit a template, then save it to the Shield?

Thanks for answering.

Can I for example, download and edit a template, then save it to the Shield?

You can't save anything to the shield. It's hardware with read-only memory that comes pre-programmed. What kind of template are you thinking about? Typically, web pages served by the Arduino are very small, since the Arduino doesn't have a lot of memory.

I see. I was thinking of a simple template with not too many images, but I guess I won´t be able to. Something that looks nice.

The Arduino doesn't have to serve up the images. Host them somewhere else, and let the Arduino simply include a link.

That's actually quite smart. Thanks for the info.

Having problems connecting the arduino+ethernet shield to the web.
Did port forwarding and still can't get the ethernet shield to connect to the web. Also tried the Web Client tutorial that appears in the Arduino page, and the Arduino can't seem to connect to google (looked for Google ip addess aswell).

Have this happened to anyone before? Any ideas of how can I fix it?

Since you have not posted the code you are tying, you may want to try the below simple client code to see if it can make a connection.

//zoomkat 11-13-10
//simple ethernet client test code
//for use with IDE 0021 and W5100 ethernet shield
//modify the arduino lan ip address as needed
//open serial monitor to see what the arduino receives
//push the shield reset button to run client again

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 102 }; // Arduino IP address
byte server[] = { 208, 104, 2, 86 }; // zoomkat's web site

Client client(server, 80);

void setup()
{
  Ethernet.begin(mac, ip);
  Serial.begin(9600);
  Serial.println("starting simple arduino client test");
  Serial.println();

  delay(1000);

  Serial.println("connecting...");

  if (client.connect()) {
    Serial.println("connected");
    client.println("GET /~shb/arduino.txt HTTP/1.0");
    client.println();
  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    Serial.println("==================================");
    Serial.println("");
    client.stop();
    for(;;);
  }
}

Tried it. No success.

The Arduino isnt able to connect to the internet. Is there anything else Im supposed to do apart from Port Forwarding? I also changed the port from 80 to 8080, and so I changed it in the broswer.

The Arduino isnt able to connect to the internet.

Using what code?

Is there anything else Im supposed to do apart from Port Forwarding?

Post your code.

Did you change the IP in Zoomkat's code? (192, 168, 1, 102) if not, is that an acceptable IP on your network?

I used Zoomkat code, and yes I changed the IP to an acceptable on for my network.

@PaulS: The code I'm talking about is the Web Client code that appears in Arduino's Official Page:http://arduino.cc/en/Tutorial/WebClient
I changed Google's IP, since the one in the example gives me negative results in the browser. To do that, I ping'ed google.com and changed the IP address according to the Ping result.

Problem solved. Apparently, my router also needed the MAC address of the device.

Sorry for double posting.
Almost everything is always working perfectly, except one thing:
After some minutes online with the server, it stops working, like after 5 minutes or so.
Here's the code, it's pretty simple, its a variant from a Example Sketch of the book: Arduino Cookbook.

/*
* WebServerPost sketch
*
*/
#if ARDUINO > 18
#include <SPI.h> // needed for Arduino versions later than 0018
#endif
#include <Ethernet.h>
#include <TextFinder.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192,168,100,110 };
byte gateway[] ={ 192, 168, 100, 1 }; // add this if needed by your router or gateway
char buffer[8]; // buffer holding the requested page name
Server server(8000);
void setup()
{
Serial.begin(9600);
Ethernet.begin(mac, ip, gateway);
server.begin();
delay(250);
Serial.println("Ready");
}
void loop()
{
Client client = server.available();
if (client) {
TextFinder finder(client );
int type = 0;
while (client.connected()) {
if (client.available()) {
// GET, POST, or HEAD
if(finder.getString("","/", buffer,sizeof(buffer))){
if(strcmp(buffer,"POST ") == 0){
finder.find("\n\r"); // skip to the body
// find string starting with "pin", stop on first blank line
// the POST parameters expected in the form pinDx=Y
// where x is the pin number and Y is 0 for LOW and 1 for HIGH
while(finder.findUntil("pinD", "\n\r")){
int pin = finder.getValue(); // the pin number
pinMode(pin, OUTPUT);
digitalWrite(pin, HIGH);
delay(250);
digitalWrite(pin, LOW);
delay(250);
}
}
sendHeader(client,"Post example");
//create HTML button to turn on pin 8
client.print("<form action='/' method='POST'><p><input type='hidden' name='pinD8'"); 
client.print(" value='1'><input type='submit' value='On'/></form>");
//create HTML button to turn on pin 9
client.print("<form action='/' method='POST'><p><input type='hidden' name='pinD9'"); 
client.print(" value='1'><input type='submit' value='On'/></form>");
client.println("</body></html>");
client.stop();
}
break;
}
}
// give the web browser time to receive the data
delay(1);
client.stop();
}
}
void sendHeader(Client client, char *title)
{
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.print("<html><head><title>");
client.print(title);
client.println("</title><body>");
}

The Ethernet Shield IC also gets incredibly hot. Any ideas?

Even some DHCP IP address will remain static.

Comcast is an example of this, the only time an IP will change is if YOU change your hardware or they do a major system change. The last IP I had was static for 3 years.

What do you mean? My public IP is actually static, I paid for one. Also, the problem is not the address, the server just doesnt host the page after a few minutes. In order for it to work again I have to reset the Shield.

I was just mentioning it since Comcast does not offer static IP's for non business accounts.

My Arduino also gets very hot, the Ethernet shield is hot but not intolerable. What hardware are you using?
I have not noticed mine resetting or turning off, but it may.

In order for it to work again I have to reset the Shield.

How are you powering the Arduino/Ethernet shield?

The Ethernet Shield IC also gets incredibly hot.

My thermometer does not have "incredibly" on it. Can you identify on a scale of say 32 to 212 where incredibly falls?

Perhaps the W5100 chip (if that's the one you have) is getting too hot. You may need a fan, or a different power supply.