Ethernet shield and Mega2560

Guys,

I installed ethernet shield 5100 into my Mega2560 arduino,
I can ping to the board, but I can't display the page into my browser in my computer ,

What's the issue here ? can anyone help ?

thanks

Please upload your sketch between code tags.

It DHCP working ?
Can you print the IP address to the serial monitor ?
Did you try the WebServer example ?
What did you type into the browser ?

Yes I tried, sometimes it's working on the browser sometimes it's not, I tried in Fedora, it's working ok...I'm using static IP, I'm not using DHCP, how can I use DHCP ?thanks
The code :

#include "SPI.h"
#include "Ethernet.h"
#include "WebServer.h"

/* CHANGE THIS TO YOUR OWN UNIQUE VALUE.  The MAC number should be
 * different from any other devices on your network or you'll have
 * problems receiving packets. */
static uint8_t mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };


/* CHANGE THIS TO MATCH YOUR HOST NETWORK.  Most home networks are in
 * the 192.168.0.XXX or 192.168.1.XXX subrange.  Pick an address
 * that's not in use and isn't going to be automatically allocated by
 * DHCP from your router. */
static uint8_t ip[] = { 192, 168, 0, 2 };
static uint8_t gateway[] = { 192, 168, 0, 1 };
static uint8_t subnet[] = { 255, 255, 255, 0 };

/* This creates an instance of the webserver.  By specifying a prefix
 * of "", all pages will be at the root of the server. */
#define PREFIX ""
WebServer webserver(PREFIX, 80);

/* commands are functions that get called by the webserver framework
 * they can read any posted data from client, and they output to the
 * server to send data back to the web browser. */
void helloCmd(WebServer &server, WebServer::ConnectionType type, char *, bool)
{
  /* this line sends the standard "we're all OK" headers back to the
     browser */
  server.httpSuccess();

  /* if we're handling a GET or POST, we can output our data here.
     For a HEAD request, we just stop after outputting headers. */
  if (type != WebServer::HEAD)
  {
    /* this defines some HTML text in read-only memory aka PROGMEM.
     * This is needed to avoid having the string copied to our limited
     * amount of RAM. */
    P(helloMsg) = "<html><head><title>ATMEGA2560 online!!</title></head>"
                  "<h1>Hi Mate,this is ATMEGA2560 Calling!</h1></html>";

    /* this is a special form of print that outputs from PROGMEM */
    server.printP(helloMsg);
  }
}

void setup()
{
  /* initialize the Ethernet adapter */
  Ethernet.begin(mac, ip, gateway);

  /* setup our default command that will be run when the user accesses
   * the root page on the server */
  webserver.setDefaultCommand(&helloCmd);

  /* run the same command if you try to load /index.html, a common
   * default page name */
  webserver.addCommand("index.html", &helloCmd);

  /* start the webserver */
  webserver.begin();
}

void loop()
{
  char buff[64];
  int len = 64;

  /* process incoming connections one at a time forever */
  webserver.processConnection(buff, &len);
}

yes I can print the IP address on serial monitor, and I type 192, 168, 0, 2 on my browser

Type this in the browser:

http://192.168.0.2

it works, but when I tried repeatedly, it's off and "waiting" all the time in my firefox, anyone knows why ?

I can ping from CMD but I got this in my browse : The connection has timed out
The server at 192.168.0.2 is taking too long to respond.

How is it connected to you router ?
Is wifi involved ?
If I use the Ethernet Shield connected to a wifi client, and try connect to it, I sometimes have that kind of error.

Do you use the newest Arduino 1.0.5 ?

Which example sketch are you using?

How is it connected to you router ?
I connected directly to my computer not with router.

Is wifi involved ?
Yes there's wifi connection in my computer

If I use the Ethernet Shield connected to a wifi client, and try connect to it, I sometimes have that kind of error.

Do you use the newest Arduino 1.0.5 ?
I'm using Arduino 1.0.4

Which example sketch are you using?

/* Web_HelloWorld.pde - very simple Webduino example */

#include "SPI.h"
#include "Ethernet.h"
#include "WebServer.h"

/* CHANGE THIS TO YOUR OWN UNIQUE VALUE.  The MAC number should be
 * different from any other devices on your network or you'll have
 * problems receiving packets. */
static uint8_t mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };


/* CHANGE THIS TO MATCH YOUR HOST NETWORK.  Most home networks are in
 * the 192.168.0.XXX or 192.168.1.XXX subrange.  Pick an address
 * that's not in use and isn't going to be automatically allocated by
 * DHCP from your router. */
static uint8_t ip[] = { 192, 168, 1, 15 };
static uint8_t gateway[] = { 192, 168, 0, 1 };
static uint8_t subnet[] = { 255, 255, 255, 0 };

/* This creates an instance of the webserver.  By specifying a prefix
 * of "", all pages will be at the root of the server. */
#define PREFIX ""
WebServer webserver(PREFIX, 80);

/* commands are functions that get called by the webserver framework
 * they can read any posted data from client, and they output to the
 * server to send data back to the web browser. */
void helloCmd(WebServer &server, WebServer::ConnectionType type, char *, bool)
{
  /* this line sends the standard "we're all OK" headers back to the
     browser */
  server.httpSuccess();

  /* if we're handling a GET or POST, we can output our data here.
     For a HEAD request, we just stop after outputting headers. */
  if (type != WebServer::HEAD)
  {
    /* this defines some HTML text in read-only memory aka PROGMEM.
     * This is needed to avoid having the string copied to our limited
     * amount of RAM. */
    P(helloMsg) = "<html><head><title>ATMEGA2560 online!!</title></head>"
                  "<h1>Hi Mate,this is ATMEGA2560 Calling!</h1></html>";

    /* this is a special form of print that outputs from PROGMEM */
    server.printP(helloMsg);
  }
}

void setup()
{
  /* initialize the Ethernet adapter */
  Ethernet.begin(mac, ip);

  /* setup our default command that will be run when the user accesses
   * the root page on the server */
  webserver.setDefaultCommand(&helloCmd);

  /* run the same command if you try to load /index.html, a common
   * default page name */
  webserver.addCommand("index.html", &helloCmd);

  /* start the webserver */
  webserver.begin();
}

void loop()
{
  char buff[64];
  int len = 64;

  /* process incoming connections one at a time forever */
  webserver.processConnection(buff, &len);
}

any ideas ?

I don't know the Webduino code, so I don't know how good it is.

Could you do a test ?
Download the newest Arduino version 1.0.5.
Create a new sketch with the Arduino libraries only, http://arduino.cc/en/Tutorial/WebServer
Change the "Ethernet.begin(mac,ip);" to "Ethernet.begin(mac);"
Without the parameter for the ip address, DHCP will be used.

Test that and see if it is stable.

Ok, I'll do it and see what's the response, thanks

if it's mac address, how can I call it on browser and ping ?
thanks

Sorry, I made a mistake.

With a router (and DHCP) the router gives the IP address, and the Arduino shows it on the serial monitor. You can use that IP in the browser.

You have it connected directly to your PC. That is possible (but a little weird). You have to use a static IP address and use that in the browser. So you should use "Ethernet.begin( mac, ip);".

Do you have a router ? for a home network ?
That is easier, since the gateway is known for that network and the DHCP will allways connect the Arduino board to the router.

Do you have a card in the Ethernet shield's SD slot. If so remove it. You can also set the SD card select inactive. You can search for more info on that. I had this intermittent connection problem and since I removed the sd card all is ok.

Now it's ok by the time I pull out the SD, but if I want to use the SD, what should I do ?

If you are using both Ethernet and SD the libraries should take care of things. Do some searching on the Internet. here's an example: Arduino Tutorials - Ethernet+SD