Ethernet shield is not working with Arduino Duemilanove ATMega328

I recently bought an Arduino Ethernet shield (Ethernet Shield WizNet W5100 R3 2012 for Arduino UNO Mega 2560 Duemilanove PoE) which I want to use with my Arduino Duemilanove ATMega 328. I connected my ethernet shield with my Arduino board and connect shield with my router using Ethernet cable.

Then I upload the following program to my Arduino board (I'm using IDE 1.0.6):

//IMPORT SOME LIBRARIES
#include <SPI.h>
#include <Dhcp.h>
#include <Dns.h>
#include <Ethernet.h>
#include <EthernetClient.h>
#include <EthernetServer.h>
#include <EthernetUdp.h>
#include <util.h>

//GLOBAL VARIABLES

char API_SERVER[] = "www.google.com";    // name address for Google (using DNS)


//Set some data for manual configuration of the arduino 
byte IP_ADDRESS[]={192,168,1,20};
byte DNS_SERVER[] = { 8,8,8,8 };
byte DEFAULT_GATEWAY[]={192,168,1,1};
byte SUBNET_MASK[]={255,255,255,0};
byte MAC_ADDRESS[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

// 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):
EthernetClient client;

void setup() {
 // Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  //Use DHCP and try to get some IP address
  if (Ethernet.begin(MAC_ADDRESS) == 0) {
    Serial.println("Failed to configure myself using DHCP, I will set static IP");
      // give the Ethernet shield a second to initialize:
    delay(1000);
    Serial.println("Setting manual network configuration");
    Ethernet.begin(MAC_ADDRESS, IP_ADDRESS,DNS_SERVER,DEFAULT_GATEWAY,SUBNET_MASK);//This will 
  }
  else{
    Serial.println("Bravo DHCP, my local IP is: ");
    Serial.println(Ethernet.localIP());

  }


  // if you get a connection, report back via serial:
  if (client.connect(API_SERVER, 80)) {
    Serial.println(":) Connected to the API server");

    // Make a HTTP request:
    client.println("GET /search?q=arduino HTTP/1.1");
    client.println("Host: www.google.com");
    client.println("Connection: close");
    client.println();
  } 
  else {
    // kf you didn't get a connection to the server:
    Serial.println("Connection to the API 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();
  }
  Serial.println("STOPPED");
}

Program compiles and uploads without any errors. When I open my serial monitor, I always get the message that Arduino couldn't connect. Is my board compatible with the shield I bought, and why I can't connect to the google?

Any suggestions?

I had problems with the R3 version of the WiFi shield if connected to a Pre-R3 version of an Arduino of any model. Maybe you have the same problem.

The R3 version shields require the IOREF pin (normally overhangs the sockets on the Arduino pre-R3 versions) to have a voltage applied. Since the Mega in my case (Duemilanove in your case) is a 5 volt IO device, I used a small jumper wire to connect the IOREF socket to the 5v socket on the shield. Problem solved. Let us know if that works for you.

I recently bought an Arduino Ethernet shield (Ethernet Shield WizNet W5100 R3 2012 for Arduino UNO Mega 2560

Is that really the MAC address that was on the shield?

Seeing all of your serial output is necessary. A paraphrase of one bit of the output is not sufficient.

That is not the problem you said you had in the original unedited post.

If connecting to google is the only problem, then try this test sketch to insure you have the correct network settings. Post the results of the serial monitor output.

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

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

void setup() {
  Serial.begin(9600);

  // disable SD SPI
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);

  Serial.print(F("Starting ethernet..."));
  if(!Ethernet.begin(mac)) Serial.println(F("failed"));
  else {
      Serial.print(F("IP: "));
      Serial.println(Ethernet.localIP());
      Serial.print(F("Subnet: "));
      Serial.println(Ethernet.subnetMask());
      Serial.print(F("Gateway: "));
      Serial.println(Ethernet.gatewayIP());
      Serial.print(F("DNS server: "));
      Serial.println(Ethernet.dnsServerIP());
}

void loop() {
}

SurferTim:
I had problems with the R3 version of the WiFi shield if connected to a Pre-R3 version of an Arduino of any model. Maybe you have the same problem.

The R3 version shields require the IOREF pin (normally overhangs the sockets on the Arduino pre-R3 versions) to have a voltage applied. Since the Mega in my case (Duemilanove in your case) is a 5 volt IO device, I used a small jumper wire to connect the IOREF socket to the 5v socket on the shield. Problem solved. Let us know if that works for you.

I connected IOREF with +5V pin. Still don't have any resutls :frowning:

PaulS:

I recently bought an Arduino Ethernet shield (Ethernet Shield WizNet W5100 R3 2012 for Arduino UNO Mega 2560

Is that really the MAC address that was on the shield?

Seeing all of your serial output is necessary. A paraphrase of one bit of the output is not sufficient.

There is no MAC address on my shield, so I used the one provided in the code.

I don't understand what you mean by "don't have any result". Try the test code I posted above and post the serial monitor output. Does it show the network settings or show "failed"?

SurferTim:
I don't understand what you mean by "don't have any result". Try the test code I posted above and post the serial monitor output. Does it show the network settings or show "failed"?

I uploaded the code that you provided. I attached the image.

In the SerialMonitor I only get the message "Starting ethernet...". When I reset my device, the same message appears in the SerialMonitor. Also I attached the image of the DHCP clients, and there is no this device in the list.

It appears you have a problem with the ethernet shield. Calling the Ethernet.begin() function is causing your Duemilanove to reboot.

Check your w5100 IC for solder bridges. That can cause that problem.
http://s681.photobucket.com/user/grue2/media/Computers/pict10852.jpg

SurferTim:
It appears you have a problem with the ethernet shield. Calling the Ethernet.begin() function is causing your Duemilanove to reboot.

Check your w5100 IC for solder bridges. That can cause that problem.
http://s681.photobucket.com/user/grue2/media/Computers/pict10852.jpg

Hm, here are some additional results. Now, the "FAILED" message appears sometimes, after I disconnected the USB cable, and connected it again.

PS: The link you provided is not working.

I didn't get a good copy on the whole link. My bad.
http://s681.photobucket.com/user/grue2/media/Computers/pict10852.jpg.html

edit: It is still restarting your Duemilanove most of the time.

SurferTim:
I didn't get a good copy on the whole link. My bad.
http://s681.photobucket.com/user/grue2/media/Computers/pict10852.jpg.html

edit: It is still restarting your Duemilanove most of the time.

Pictures of my IC attached.

Those are solder bridges. If that is a new shield, I would contact your supplier, explain what you found, and request an exchange for a good shield.

SurferTim:
Those are solder bridges. If that is a new shield, I would contact your supplier, explain what you found, and request an exchange for a good shield.

Yep, you are right. Will contact the seller.

Thank you for your support :slight_smile: