Ethernet shield not connecting?

Hi there,
I´m trying to test my new ethernet shield (is a generic one, and it loks just like this: http://arduino.cc/en/uploads/Guide/ArduinoWithEthernetShield.jpg).

The thing is that I´m trying to test the shield without any success. I know that there´s no shield issue, because there was this one time that it worked, with the webserver example that comes with the ethernet library, but it suddenly stop working.

My ISP told me that they don´t close any ports, and they specially use the 8080 and 8021. I´ve tried port 80 and the other two without any luck.

I have an arduino mega 2560, and I´ve just insert the ethernet shield on top of it, in the usual way.

I´ve then tried this Hello world code that comes with the webduino library (webserver.h).

/* 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[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE };


/* 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, 2, 106 };

/* 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, 8021);

/* 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) = "<h1>Hello, World!</h1>";

    /* 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);
}

As my ethernet shield didn´t came with any mac address printed in the back, I´ve tried to find it out using my router:

Under Network Settings, I´ve search for "NUMBER OF DYNAMIC DHCP CLIENTS", and found this one, that I think it´s the arduino:

Host Name: WIZnetCCDE02
IP Address: 192.168.2.106
**MAC Address: 00:aa:bb:cc:dd:ee **
Expired Time: 6 Days 22 Hours 47 Minutes

Now, I´ve checked (cmd/ipconfig in my windows dos console):
IPV4 Address: 192.168.2.104
Subnet Mask: 255.255.255.0
Gateway: 192.168.2.2

My pc is connected to the internet using wifi.
I tried to ping the address: 192.168.2.106, and this is the result:

ping 192.168.2.106
pinging 192.168.2.106 with 32 bytes of data:
Reply from 192.168.2.104: Destination host unreachable.

What should I do? Any ideas? Thanks for your help!!

Rosamunda

The example code provided on the Arduino site has some problems. This is my server code in the playground.
http://playground.arduino.cc/Code/WebServerST

You might also want to search the forum for zoomkat's server code. He is really good using the SD card with the w5100 when you get comfortable with the vanilla server code.

Thanks for your reply!
I´ve tried that code with IPAddress ip( 192,168,2,106 );
and the webpage doesn´t connect when I type that address, but the Monitor serie says "ready"...

About zoomkat's code, I´m trying to install it right now.

You must know the network settings for your localnet. If the ip is not in the localnet's subnet, the server will not respond. Your network may not be a 192.168.2.x subnet.

Look in the computer that you are trying to connect to the Arduino with. What are the network settings on it?

Thanks for your reply.
I´ve tried ipconfig command in the console of the PC where i´m trying to connect the arduino, and this is the output:
IPV4 Address: 192.168.2.104
Subnet Mask: 255.255.255.0
Gateway: 192.168.2.2

I thought those were the network settings. Are there any other place I should go besides the console?

Thanks again!

If this is the response you got, something is not right with the network. It should say "timed out" if the device is not present, not "destination host unreachable". That is a routing problem.

ping 192.168.2.106
pinging 192.168.2.106 with 32 bytes of data:
Reply from 192.168.2.104: Destination host unreachable.

What brand/model router are you using?

Thanks!!
D-Link Dir-600

Update:
When I try to ping it from the router tool "ping test", I do get "Request timed out."
I´ve got that unreachable response using the dos console (cms/ipconfig).

Do you get an ethernet port light on the router when you plug in the Arduino? Do the lights on the shield CAT5 connector light up?

Use that ping utility in the router until you can ping the Arduino. Otherwise you are wasting time.

edit: The ethernet ports use a different subnet than the wireless, according to the manual. The wifi uses 192.168.2.x, and the ethernet ports use 192.168.0.x
http://www.dlink.com/-/media/Consumer_Products/DIR/DIR%20600/Manual/DIR_600_B_2_Manual_EN_UK.pdf

Try assigning the Arduino
ip = 192.168.0.2
subnet = 255.255.255.0
gateway = 192.168.0.1

Then try to ping 192.168.0.2 from the router.

IT WORKED!!
Thanks for your help!! :slight_smile:
I´ve been into this for two days now... it would have taken me forever without your help!
Thanks!!!!

We are not finished yet. Can you ping the Arduino from the wifi computer now? Or do you get the "destination host unreachable" message?

Oh I see...
Yes, I´ve ping the address assigned to the arduino, and it was pinging, finished the process and didn´t loose a single packet!

:slight_smile:

Now we are finished! :slight_smile:

Again, many, many, many! thanks for being so kind to help me out!