Pages: 1 [2] 3   Go Down
Author Topic: Controlling Arduino via Web  (Read 3081 times)
0 Members and 1 Guest are viewing this topic.
Santo Domingo, Dominican Republic
Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
Keep it simple.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all, I've decided using an Arduino Ethernet Shield after all.

I have some questions though, questions that if answered, will make me able to comprehend how the Ethernet Shiled + Arduino combo works.

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.
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?
3.- If it is indeed possible to make a web server to host a page, can I design that page in PHP/HTML?
Logged

Keep it simple.

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.

Quote
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.

Quote
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.
Logged

Santo Domingo, Dominican Republic
Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
Keep it simple.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Thanks for answering.
Logged

Keep it simple.

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Santo Domingo, Dominican Republic
Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
Keep it simple.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Keep it simple.

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Santo Domingo, Dominican Republic
Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
Keep it simple.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Keep it simple.

Santo Domingo, Dominican Republic
Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
Keep it simple.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Keep it simple.

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9470
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Code:
//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(;;);
  }
}
 
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Santo Domingo, Dominican Republic
Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
Keep it simple.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Tried it. No success.
Logged

Keep it simple.

Santo Domingo, Dominican Republic
Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
Keep it simple.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Keep it simple.

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The Arduino isnt able to connect to the internet.
Using what code?

Quote
Is there anything else Im supposed to do apart from Port Forwarding?
Post your code.

Logged

Chester, UK
Offline Offline
Sr. Member
****
Karma: 2
Posts: 489
Trying to return the love to none logic level MOSFETS
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

If your system involves lethal voltages/life critical/flamable elements - you probably shouldn't need to ask.
The Arduino != PC.

Santo Domingo, Dominican Republic
Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
Keep it simple.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

Keep it simple.

Santo Domingo, Dominican Republic
Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
Keep it simple.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Keep it simple.

Pages: 1 [2] 3   Go Up
Jump to: