ERROR: Failed to configure Ethernet using DHCP

for arduino 1.0
i have a ethernet shield and want to know the local IP address
then copy that program:
#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = {
0x90, 0xA2, 0xDA, 0x00, 0x4F, 0xAC };

// 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() {
// start the serial library:
Serial.begin(9600);
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
for(;:wink:
;
}
// print your local IP address:
Serial.println(Ethernet.localIP());

}

void loop() {

}
program copy this site ----> Ethernet - Arduino Reference
but I get error: Failed to configure Ethernet using DHCP

help me

Is your Arduino connected to a router with an Ethernet cable? Does the router show activity (usually a blinking light) on the Arduino's ethernet port when you reset the Arduino?

Same issue here. With dhcp the Ethernet.begin(mac) dies with no feedback. It seems even, that it requires a power cycling to bring the Arduino back to ethernet live. I assume that this isn't just a software issue. Hopefully I am wrong

One of the things the below test code does is send the arduino ip address to the serial monitor.

//zoomkat 2-13-12
//DNS and DHCP-based web client test code
//for use with IDE 1.0
//open serial monitor and send an e to test
//and to see test result
//for use with W5100 based ethernet shields
//browser equivelant URL: 
// http://web.comporium.net/~shb/arduino.txt
//note that the below bug fix may be required
// http://code.google.com/p/arduino/issues/detail?id=605 

#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
char serverName[] = "web.comporium.net"; // zoomkat's test web page server
EthernetClient client;

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

void setup(){
  Serial.begin(9600); 
  Serial.println("DNS and DHCP-based web client test 2/13/12"); // so I can keep track of what is loaded
  Serial.println("Send an e in serial monitor to test"); // what to do to test
  // start the Ethernet connection:
  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.print("Arduino IP address: ");
  for (byte thisByte = 0; thisByte < 4; thisByte++) {
    // print the value of each byte of the IP address:
    Serial.print(Ethernet.localIP()[thisByte], DEC);
    Serial.print("."); 
  }
  Serial.println();
  Serial.println();
}

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 /~shb/arduino.txt HTTP/1.0"); //download text
    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
    Serial.print(c); //prints byte to serial monitor 
  }

  Serial.println();
  Serial.println("disconnecting.");
  Serial.println("==================");
  Serial.println();
  client.stop(); //stop client

}

If you are using IDE v1.0, then zoomkat covered one of the challenges:
http://code.google.com/p/arduino/issues/detail?id=605

The other is the SD card SPI. Do you have a microSD card in the slot?

isabe2244:
for arduino 1.0
i have a ethernet shield and want to know the local IP address
then copy that program:
#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = {
0x90, 0xA2, 0xDA, 0x00, 0x4F, 0xAC };

// 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() {
// start the serial library:
Serial.begin(9600);
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
for(;:wink:
;
}
// print your local IP address:
Serial.println(Ethernet.localIP());

}

void loop() {

}
program copy this site ----> Ethernet - Arduino Reference
but I get error: Failed to configure Ethernet using DHCP

help me

johnwasser:
Is your Arduino connected to a router with an Ethernet cable? Does the router show activity (usually a blinking light) on the Arduino's ethernet port when you reset the Arduino?

i've conected my arduino ethernet shield to the computer via the etherenet cable since i do not have router and i am facing the same error : Failed to configure Ethernet using DHCP. the lights flash and the rx tx lights flash as well, im trying to setup my ethernet shield for the very first time and im still new to all this, i would greatly appreciate it if you could help me diagnose this problem

mangtee:
i've conected my arduino ethernet shield to the computer via the etherenet cable since i do not have router and i am facing the same error : Failed to configure Ethernet using DHCP. the lights flash and the rx tx lights flash as well, im trying to setup my ethernet shield for the very first time and im still new to all this, i would greatly appreciate it if you could help me diagnose this problem

If you don't have a router that is supplying the DHCP service you will either have to use manual configuration or use something like "Internet Sharing" on your PC to make it act as a router with DHCP services.

thank you for the response :smiley:
i had to restart my machine, probably to reset the ethernet
and i used this code to test my connection and Woohoo! it worked with my static ip
here's the code i used to test

//zoomkat 12-08-11
//simple client test
//for use with IDE 1.0
//open serial monitor and send an e to test
//for use with W5100 based ethernet shields
//note that the below bug fix may be required
// Google Code Archive - Long-term storage for Google Code Project Hosting.

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

byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x3E, 0x48 }; //physical mac address
byte ip[] = { 192,168,137, 170 }; // ip in lan assigned to arduino
//byte gateway[] = { 192, 168, 0, 1 }; // internet access via router
//byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
byte myserver[] = { 208, 104, 2, 86 }; // zoomkat web page server IP address
EthernetClient client;
//////////////////////

void setup(){

Ethernet.begin(mac, ip);
//Ethernet.begin(mac, ip, subnet, gateway);
Serial.begin(9600);
Serial.println("Better client test 12/01/11"); // so I can keep track of what is loaded
Serial.println("Send an e in serial monitor to test"); // what to do to test
}

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(myserver, 80)) { //starts client connection, checks for connection
Serial.println("connected");
client.println("GET /~shb/arduino.txt HTTP/1.0"); //download text
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
Serial.print(c); //prints byte to serial monitor
}

Serial.println();
Serial.println("disconnecting.");
Serial.println("==================");
Serial.println();
client.stop(); //stop client

}

thank you once again XD
i'd like to know how i can use it to connect it to my local wampserver with mysql so that i can store a cellnumber and serial number remotely.
I'm going to hook up a 4x3 keypad, 20x4 lcd in 4 bit mode, ethernet shield and the arduino uno r3.
any suggestions will be greatly appreciated

i'd like to know how i can use it to connect it to my local wampserver with mysql so that i can store a cellnumber and serial number remotely.

All that you need to do is change the GET request.

mangtee... i tried your software... when i sent an'e' as requested it is telling me that i got disconnected.... do you have an idea why this can happen?