Arduino program stop at Ethernet.begin();

Hi,

I have a problem with my arduino UNO and Ethernet shield, in fact i try to use the DHCPAdressPrinter, in the program exemple, but in fact, the program don't go after ethernet.begin() and my card never get connected :confused: i have FDX and LINK in orange , act is blinking sometime, and 100m in green, and the ethernet port is green and orange but don't blink , can you help me ?

Thanks alot !
Best regards !

Do you have a SD card in the shield's slot?

If the DHCP begin fails, it takes 2 minutes to return a fail. Does it return a fail, or just freezes there?

SurferTim:
Do you have a SD card in the shield's slot?

If the DHCP begin fails, it takes 2 minutes to return a fail. Does it return a fail, or just freezes there?

I don't have SD plugged in , and it shows nothing, just freezing apparently :confused:

I also tryed this code and in this code :

#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, 15);

// 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);
  Serial.println("Hi");
  while (!Serial) {
    Serial.println("blup");
    ; // wait for serial port to connect. Needed for native USB port only
  }


  // start the Ethernet connection and the server:
  Serial.println("eth begin");
  Ethernet.begin(mac, ip);
  Serial.println("srv begin");
  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 disconnected");
  }
}

it freez at server.begin();

Try this test code. It checks the SPI bus. If the serial monitor shows 192.168.0.2, then you are ok there. If not, you have a SPI problem.

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

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,0,2);

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

  // disable SD card if one in the slot
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);

  Serial.println("Starting w5100");
  Ethernet.begin(mac,ip);

  Serial.println(Ethernet.localIP());
}

void loop() {
}

SurferTim:
Try this test code. It checks the SPI bus. If the serial monitor shows 192.168.0.2, then you are ok there. If not, you have a SPI problem.

#include <SPI.h>

#include <Ethernet.h>

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,0,2);

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

// disable SD card if one in the slot
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);

Serial.println("Starting w5100");
  Ethernet.begin(mac,ip);

Serial.println(Ethernet.localIP());
}

void loop() {
}

It shows :

Starting w5100
0.223.223.223

Then you have a SPI problem.

edit: Are you certain it is a w5100 IC? Or maybe a w5200 or w5500?

SurferTim:
Then you have a SPI problem.

edit: Are you certain it is a w5100 IC? Or maybe a w5200 or w5500?

This is a W550

If you are using the standard ethernet library included with the IDE, then that is your problem. I use this one.

I have the W5500, can you tell me how to use your library for it ?

What OS does your PC use? I can help you if it is Linux (Ubuntu). I'm not a Windows person.

PC, i added the library it said installed, now , how i use it ? :smiley:

When I installed mine (Linux/Ubuntu), I put it in my "$HOME/Arduino/libraries/" directory. I use it just like the original. The IDE compiler displays a message that it has found two ethernet libraries, and it is using the one in "Arduino/libraries/" directory.

It seems to works, it print me an ip , i'll try the Webserver sketch and i'll tell you if it works !

If it is now showing the correct IP, you should be good to go.

It works perfectly thanks alot!