I am currently making a design that uses the Arduino's Ethernet shield. I am using the PushingBox API for Arduino, and have tried it with my Arduino Mega (2560) with the ethernet shield attached to the router. When I did this, however, it displayed a message on my serial monitor saying Failed to configure Ethernet using DHCP. The model for my Ethernet Shield is a W5200 Seeed Studio Ethernet Shield, and I am using the libraries that Arduino provides. I do not have an SD card inserted and the DHCP on all other wired devices works. Any help is greatly appreciated.

The code (in case):

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

byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x19 };   // Be sure this address is unique in your network

//Your secret DevID from PushingBox.com. You can use multiple DevID  on multiple Pin if you want
char DEVID1[] = "{[I have replaced this with my DevID]}";        //Scenario : "The mailbox is open"

//Numeric Pin where you connect your switch
uint8_t pinDevid1 = 3; // Example : the mailbox switch is connect to the Pin 3

// Debug mode
boolean DEBUG = true;
 //   End    //

char serverName[] = "api.pushingbox.com";
boolean pinDevid1State = false;                // Save the last state of the Pin for DEVID1
boolean lastConnected = false;                 // State of the connection last time through the main loop

// 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() {
  pinMode(pinDevid1, INPUT);

  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    Serial.println("Please reconfigure the settings and try again.");
    // no point in carrying on, so do nothing forevermore:
    Serial.println("Ethernet ready");
    // print the Ethernet board/shield's IP address:
    Serial.print("My IP address: ");
  // give the Ethernet shield a second to initialize:

void loop()
      // Listening for the pinDevid1 state
      if (digitalRead(pinDevid1) == HIGH && pinDevid1State == false) // switch on pinDevid1 is ON 
        if(DEBUG){Serial.println("pinDevid1 is HIGH");}
        pinDevid1State = true;
        //Sending request to PushingBox when the pin is HIGH
       if (digitalRead(pinDevid1) == LOW && pinDevid1State == true) // switch on pinDevid1 is OFF
        if(DEBUG){Serial.println("pinDevid1 is LOW");}
        pinDevid1State = false;
        //Sending request to PushingBox when the pin is LOW
        //sendToPushingBox(DEVID1);    //Here you can run an other scenario by creating a DEVID2 variable

      //DEBUG part
      // this write the respons from PushingBox Server.
      // You should see a "200 OK"
      if (client.available()) {
        char c = client.read();

      // if there's no net connection, but there was one last time
      // through the loop, then stop the client:
      if (!client.connected() && lastConnected) {
      lastConnected = client.connected();

//Function for sending the request to PushingBox
void sendToPushingBox(char devid[]){

  if (client.connect(serverName, 80)) {

    if(DEBUG){Serial.println("sendind request");}
    client.print("GET /pushingbox?devid=");
    client.println(" HTTP/1.1");
    client.print("Host: ");
    client.println("User-Agent: Arduino");
  else {
    if(DEBUG){Serial.println("connection failed");}

If the code for the DHCP error is removed, it does display an external IP address, but actual HTTP requests do not work. I tried port forwarding and that did not work either.

EDIT: Now, unusually, it gives me an IP address WITHOUT the ethernet cord connected.

  • can you get it working without all the pushingbox stuff?
    – JayEye
    May 12, 2016 at 1:02
  • No, not even the WebClient sample that Arduino provides works.
    – Cowboy433
    May 12, 2016 at 5:32
  • so what was the point of putting in all the pusingbox code?
    – JayEye
    May 12, 2016 at 8:18
  • also: how do you know you don't have a defective shield?
    – JayEye
    May 12, 2016 at 8:18
  • If you have connected directly to the router are you sure you have the right sort of cable. Some older router/switches/hubs require crossed network cables. Can you switch the cable with a cable that is connected to a device that you know is working? May 12, 2016 at 12:32

1 Answer 1


If I understood your problem correctly then you might want to check this out, it's more or less the same thing :D

DHCP Failing on Arduino Uno

  • The page is no longer available
    – Ohbhatt
    Jul 21, 2023 at 10:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.