Problem with ethernet shield

Hello ! i have a arduino Ethernet Shield on top of an arduino MEGA and have connected the mega through serial to my laptop and through UTP port on the Ethernet Shield to my router .

I've tried the "search arduino on google" example ( where i corrected google's ip , the example was old ) and it doesn't work ( it doesn't seem to connect to the internet , i get on the serial : "connecting... /connection failed / disconnecting." )

my UTP cable is working fine.. i've tested it on my laptop .

Any ideas why ? Maybe there is something i'm missing .. :-?? Here is my code :

/*
  Web client
 
 This sketch connects to a website (http://www.google.com)
 using an Arduino Wiznet Ethernet shield. 
 
 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 
 created 18 Dec 2009
 by David A. Mellis
 
 */

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

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192,168,1,177 };
byte server[] = { 209,85,148,147 }; // Google

// Initialize the Ethernet client library
// with the IP address and port of the server 
// that you want to connect to (port 80 is default for HTTP):
Client client(server, 80);

void setup() {
  // start the Ethernet connection:
  Ethernet.begin(mac, ip);
  // start the serial library:
  Serial.begin(9600);
  // give the Ethernet shield a second to initialize:
  delay(1000);
  Serial.println("connecting...");

  // if you get a connection, report back via serial:
  if (client.connect()) {
    Serial.println("connected");
    // Make a HTTP request:
    client.println("GET /search?q=arduino HTTP/1.0");
    client.println();
  } 
  else {
    // kf you didn't get a connection to the server:
    Serial.println("connection failed");
  }
}

void loop()
{
  // if there are incoming bytes available 
  // from the server, read them and print them:
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    // do nothing forevermore:
    for(;;)
      ;
  }
}

the ARDUINO MEGA is ARDUINO MEGA 2560

I found this one online 216.239.51.99. i did a google search for google's IP. You may also try to ping their website through the c-prompt.

216.239.51.99 is not good . if you don't believe me , copy-paste in your browsers URL . The problem is with the device or network . I've enabled anything i can in my router ( including MAC filtering ) and it just won't work .

A also have a Mega 2560 and the Ethernet board. (And a few other Sparkfun breakout boards and loose devices)

I presume that you are running Arduino Sketch software V022.

To put it politely the Official Ethernet board is FLAKY!

Try running some of the other Ethernet Sketches included and let us know if they work. For example the one that publishes sensor values to a "Web Page". I will bet that you get absolute garbage sometimes and that other times it will work.

I don't know if it is software or hardware. I looked at the code and the implementation is pretty minimal. Someone pointed out that the the SPI interface (CS) is not correctly released -- left High or low as opposed to floating when the board should be disconnected.

I have successfully programmed the board to send data to my Delphi Program that stores the data in a DB -- millions of point samples for Low Frequency Vibration testing. However....it often takes 20 to 30 tries for the board to respond to the start command and and sometimes as many to respond to the stop command.... The lights (and my scope) say that the board is "working" and receiving or sending....

Sometimes the "Start" command I send is garbled as in the board receives "STaRt" or even some incorrect letters...

I send the received command to the serial port -- so I can see what was received.

Good Luck.

Hello ! The problem may be hardware + software. The ethernet shield isn't compatible with my MEGA 2560 ( I know ! right ?! ) , probably they are different generations ( anyway it just seems wrong and easily misleading ; big fault by arduino concerning platform design ) .. It seems that the team from arduino may have modified the pins on mega.

I've got a response on stackoverflow . Shows how to alter the board + software .

Hope this helps for anyone interested : Arduino Ethernet shield: it just won't work! - Electrical Engineering Stack Exchange .

Be advised that you may not be able to connect to big sites like google using an IP address. If you want to try a simple client test, you can try the below (adjust the arduino lan ip address as needed).

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

Besides the fact that i changed the server's address ( it's now 208.104.244.29 ) , i didn't do anything to your code and it still doesn't work . :frowning:

I've tried the shield with arduino uno and it works ! So .. the Mega isn't compatible with the ethernet shield