Arduino DHCP failed to configure

Andrew picture Andrew · Jan 5, 2012 · Viewed 21.8k times · Source

I am using the example ethernet sketch for a web client that comes bundled with the Arduino software without changing a thing except for the firmware address, which I changed to the one printed on the back of the ethernet shield.

Whenever I connect the Arduino to my network and view the serial monitor, the only message I get is that it "Failed to configure Ethernet using DHCP".

I have setup my Arduino Mega 2560 with an ethernet shield, correctly connecting ports 50 to MISO, 51 to MOSI, 52 to SCK, and 10 to SS (a.k.a. ETHCS as it is printed on the ethernet board).

Do you guys have any idea why this DHCP error would be happening?

Here is my code:

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

byte mac[] = {  0x90, 0xA2, 0xDA, 0x00, 0x73, 0xE4 }; //ethernet mac
IPAddress server(192, 168, 1, 9); //valid server IP in my network

EthernetClient client;

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

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");

    for(;;)
      ;
  }

  delay(1000);
  Serial.println("connecting...");

  if (client.connect(server, 80)) {
    Serial.println("connected");

    client.println("GET /search?q=arduino 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.");
    client.stop();

    for(;;)
      ;
  }
}

Answer

unknowndomain picture unknowndomain · Feb 10, 2013

The solution that fixed this for me was to remove the Micro SD card from the slot, I saw your issue was related to a fault but others having this issue should remove the Micro SD card after turning off the Arduino.