Ethernet Shield Connection Problem

Hi,

I try to test my new ethernet shield Wiznet W5100, I just plug into my Arduino Uno, It comes without unique MAC adress, and I used this;

Examples>Ethernet>DhcpAdressPrinter, It gives nothing at Serial Monitor.

Then I try to use this most common mac adress 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 or 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED , and I used this example;

Examples>Ethernet>WebServer

It says "server is at 0.0.0.0" at Serial Monitor.

I searched this results and I found that I should disable the SD card pins so I added this lines at void setup(),

pinMode(4,OUTPUT);
digitalWrite(4,HIGH);

It says the same thing at Serial Monitor.

I searched this results and I found at link:Ethernet Shield Not taking address - Networking, Protocols, and Devices - Arduino Forum this ICSP pins cannot connect correctly, beacuse the lenght of the pins at ethernet shield is too long for the right connection to ICSP pins. So I cut the 1/8 off pins then I tried again.

Now it says "server is at 0.0.0.1" at Serial Monitor. When I reset the etherned shield about 24 times, It gives random things at below.

Also I tried to remove shield from Arduino and wired only ICSP pins and D10, but it gave the same result.

I checked my modem settings and there is no MAC Adress filtering, also I disabled SPI firewall.

I used my Local IP adress.If someone can help me, I will be glad,

Thanks,

Here is my codes;

#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 };
IPAddress ip(192,168,0,106);

// Initialize the Ethernet server library
// with the IP address and port you want to use 
// (port 80 is default for HTTP):
EthernetServer server(80);

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


  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}


void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
	  client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            int sensorReading = analogRead(analogChannel);
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(sensorReading);
            client.println("
");       
          }
          client.println("</html>");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } 
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disonnected");
  }
}

I have another post with exactly the same problem you have. Take a look at this post:
http://forum.arduino.cc/index.php?topic=279653.0
Are you certain you have a w5100 IC on your shield? Can you post a link to your shield?

Are both the Uno and the Ethernet Shield from Ebay ? I have never heard that cutting the wires was needed.
Do they have a brand ? They should both be version 'R3'.

Use the newest Arduino IDE. Version 1.0.6 or 1.5.8 BETA.

First of all, try to make it connected. Check the return value of Ethernet.begin() and use DHCP so the router gives an IP number to the Arduino.

Sometimes a router does not accept the default mac address (DEADBEEFFEED). So if the sketch below doesn't work, try another mac address.

Could you try this :

#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 };

void setup()
{
  Serial.begin( 9600); 
  
  // Using the Ethernet Shield, pin 10 (SS) should be output,
  // and pin 4 and pin 10 are used for chip select. Disable both.
  pinMode( 10, OUTPUT);
  digitalWrite( 10, HIGH);     // disable this chip select
  pinMode( 4, OUTPUT);
  digitalWrite( 4, HIGH);      // disable this chip select

  Serial.println(F( "\nStarting Ethernet..."));

  // Ethernet.begin without 'ip' parameter starts the DHCP
  if( Ethernet.begin(mac) == 0) 
  {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }
  
  // print your local IP address.
  Serial.println(F( "Ethernet started."));
  Serial.print(F( "Local IP = "));
  Serial.println( Ethernet.localIP());
}

void loop(){
}

If assigning a static IP doesn't work, there is a problem with the SPI bus or the SPI side of the Arduino w5100. This has nothing to do with the router. Unless the O.P. can get the static IP assignment to work, a dhcp request will not work either.

You can get the static IP assignment to work without the w5100 even being connected to a router if the SPI bus is functioning.

SurferTim, Okay, I think you told me that before. I guess I just don't like a static ip...

hitnrj12, can you make a photo of the boards. I'm curious what they are (and what I should avoid to buy).

Basic client test code. Cutting a pin may make things worse.

//zoomkat 11-04-13
//simple client test
//for use with IDE 1.0.1
//with DNS, DHCP, and Host
//open serial monitor and send an e to test client GET
//for use with W5100 based ethernet shields
//remove SD card if inserted
//data from myIP server captured in readString 

#include <SD.h>
#include <SPI.h>
#include <Ethernet.h>
String readString;

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

char serverName[] = "checkip.dyndns.com"; // zoomkat's test web page server
EthernetClient client;

//////////////////////

void setup(){

  Serial.begin(9600); 
  Serial.println("client readString test 11/04/13"); // so I can keep track of what is loaded
  Serial.println("Send an e in serial monitor to test"); // what to do to test
  Serial.println();

  // disable w5100 while setting up SD
  pinMode(10,OUTPUT);
  digitalWrite(10,HIGH);
  Serial.println("Starting SD..");
  if(!SD.begin(4)) Serial.println("SD failed or no SD card inserted");
  else Serial.println("ok");

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }
}

void loop(){
  // check for serial input
  if (Serial.available() > 0) //if something in serial buffer
  {
    byte inChar; // sets inChar as a byte
    inChar = Serial.read(); //gets byte from buffer
    if(inChar == 'e') // checks to see byte is an e
    {
      sendGET(); // call sendGET function below when byte is an e
    }
  }  
} 

//////////////////////////

void sendGET() //client function to send/receive GET request data.
{
  if (client.connect(serverName, 80)) {  //starts client connection, checks for connection
    Serial.println("connected");
    client.println("GET / HTTP/1.1"); //download text
    client.println("Host: checkip.dyndns.com");
    client.println("Connection: close");  //close 1.1 persistent connection  
    client.println(); //end of get request
  } 
  else {
    Serial.println("connection failed"); //error message if no client connect
    Serial.println();
  }

  while(client.connected() && !client.available()) delay(1); //waits for data
  while (client.connected() || client.available()) { //connected or data available
    char c = client.read(); //gets byte from ethernet buffer
    readString += c; //places captured byte in readString
  }

  //Serial.println();
  client.stop(); //stop client
  Serial.println("client disconnected.");
  Serial.println("Data from server captured in readString:");
  Serial.println();
  Serial.print(readString); //prints readString to serial monitor 
  Serial.println();  
  Serial.println();
  Serial.println("End of readString");
  Serial.println("==================");
  Serial.println();
  readString=""; //clear readString variable

}

Peter_n,

I am using the latest version of Arduino IDE 1.0.6

I tried to use your code, with both default mac adress (0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 or 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED ) , it should be failed or started but It gives nothing, the results is :

the picture of wiznet5100 shield that I use :

zoomkat I also try to use your code, I think Ethernet.begin(); doesn't work, the result is :

SurferTim, I got problem with SPI bus you mean? I don't understand exactly.
the link: http://www.robotistan.com/Arduino-Ethernet-Shield-Wiznet-W5100-Klon,PR-1793.html

hitnrj12, I think we (SurferTim and zoomkat and me) are convinced now that it is an SPI bus problem.
Thanks for the information. That is typical an Ethernet Shield from Ebay.
If both the Uno and the Ethernet Shield are compatible with version 'R3' it should be allright.

The SPI bus is a few pins that are used to communicate between the Uno and the Ethernet Shield.
The SPI bus is used for the Ethernet chip (W5100) and for the SD card.
Since you can not communicate with both, you have a problem with the SPI bus.

I have the same Ethernet Shield. It is not version 'R3' but an older version (let's call it version 'R2'). At the moment I have it connected to an Arduino Mega 2560 board, which is also not version 'R3' but an older one.
Does that Arduino Uno board have the text 'R3' at the bottom ?

At the bottom of the Ethernet Shield are 6 sockets. Those are used for the SPI bus. Do they connect well with the 6 pins on the Arduino Uno board ?
Do you have a multimeter to check that ?
I compared your photo with my board, and I have the 6 pins a little vissible sticking out at the top. So yours are soldered too low, and that might be the reason that you had to cut them.

Peter_n, I check with multimeter, pin connections are ok. yes my Arduino Uno R3, I also try to connect pins D10, D11, D12, D13, GND and 5V, and it gives 0.0.0.0 again, I also get the same result with ENC28J60 ethernet module I cannot work on it, so I decided to buy a new ethernet shield (W5100) but I got the same problem.

also tried like this, it gives 1.2.2.2 or 2.2.2.2 again :

Don't connect the SPI lines to D11-D13 on the ethernet shield. The new ethenet shields don't have the SPI lines connected there. The only SPI data line connections are on the ICSP pins on the ethernet shield. It allows you to connect that shield to a Mega and stil be able to use D11 to D13 for GPIO.

The standard ethernet library will not work with the enc28j60 IC.

That second picture (Uno pins to the 6-pins header on the Ethernet shield) should also work.
Is that an official Arduino Uno R3 ? It seems like one.
When you buy also an official Ethernet Shield R3, it should work right away.

It is possible that the Arduino Uno has a problem. Can you check the board with a magnifier for solder drops, shortcuts and so on. Perhaps you could write a test that toggles the pins 4,10,11,12,13 and check that with a led or multimeter.

Did you buy the second Ethernet Shield from the same vendor ? Perhaps they have the same production fault. It happens.

Perhaps your USB power is too weak. It is possible that the leds on the Ethernet Shield are on, but it doesn't have enough power to run.
Try a power supply of 7 to 12V (preferrably 7.5V or 9V) to the barrel jack of the Uno.

I think you can attach the shield in the normal way. An Ethernet Shield R2 should work with Uno R3.

When you really can't make it work, you could try that ENC28J60 module.
It needs 3.3V to power it. And you need the UIPethernet or EtherCard library for the ENC28J60.
You should be able to make that work.

When the ENC28J60 works, you might try buying a third W5100 Ethernet Shield, but buy an official one, or a different clone.

Thanks for help but I still suffering from the same issue. I got Arduino Ethernet Shield V1.1 now. It's based ENC28j60 and it has no connections like wiznet shield, at ICSP pins between shield and Uno. I used EtherCard library, and I try to test my shield, the result is the same. It stack into testDHCP line. It should be says Failed to access Ethernet controller or Setting up DHCP but it says nothing.Any advice?

Arduino Ethernet Shield V1.1

Here is Codes:

#include <EtherCard.h>

static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

byte Ethernet::buffer[700];

void setup () {
  Serial.begin(57600);
  Serial.println(F("\n[testDHCP]"));

  Serial.print("MAC: ");
  for (byte i = 0; i < 6; ++i) {
    Serial.print(mymac[i], HEX);
    if (i < 5)
      Serial.print(':');
  }
  Serial.println();
  
  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) 
    Serial.println(F("Failed to access Ethernet controller"));

  Serial.println(F("Setting up DHCP"));
  if (!ether.dhcpSetup())
    Serial.println(F("DHCP failed"));
  
  ether.printIp("My IP: ", ether.myip);
  ether.printIp("Netmask: ", ether.netmask);
  ether.printIp("GW IP: ", ether.gwip);
  ether.printIp("DNS IP: ", ether.dnsip);
}

void loop () {}

Result:

Finally problem is solved, I try to work on another Arduino Uno, and its works well. Probably my original R3 Uno has some SPI pin conenction issues or something else. I used wiznet ethernet shield, and I used DHCPAdressPrinter example, results is fine. I can show my localIP now. Thanks