DHCP Fails Actiontec MI424WR from Verizon

Hello all,

I'm sure this will exasperate some, but I'm at my wits end.

Hardware:

Arduino Mega2560
Arduino Ethernet Shield
Actiontec MI424WR from Verizon

I've loaded the DhcpAddressPrinter sketch on to the Arduino and I consistently get Failed to connect to DHCP server. I have factory reset the router and tried again to no avail.

My main goal is to set up Teleduino on the Arduino. When I use the Ethernet sketch from Teleduino the Arduino never connects...never shows up in my router's list of connected devices.

I've also set DHCP to false inside the Teleduino sketch and added my router configuration, making sure to pick an IP outside the DHCP in concurrence with setting up a static IP with the router using the same MAC address and IP as is in my Sketch....to no avail.

Either the router hates me...the Ethernet shield or I'm an idiot. I'm willing to accept any or all at this point.

Any help figuring this out is appreciated!

Teleduino Sketch with Static IP code:

/*
  Teleduino2560EthernetClientProxy.ino - Teleduino2560EthernetClientProxy example
  Version 2560-0.1.2
  Nathan Kennedy 2009 - 2014
  http://www.teleduino.org

  This sketch is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

#include <EEPROM.h>
#include <Servo.h>
#include <Wire.h>
#include <Teleduino2560.h>

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

// User configurable variables
byte useDhcp = false;
byte useDns = true;
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };
IPAddress deviceIp(192, 168, 1, 252); // Only if useDhcp is false
IPAddress gatewayIp(192, 168, 1, 1); // Only if useDhcp is false
IPAddress dnsIp(192, 168, 1, 1); // Only if useDhcp is false
IPAddress subnet(255, 255, 255, 0); // Only if useDhcp is false
IPAddress serverIp(173, 230, 152, 173); // Only if useDns is false
char serverName[] = "us01.proxy.teleduino.org"; // Only if useDns is true
unsigned int serverPort = 5353; // Can be set to either 53 or 5353
byte statusLedPin = 8;

// User configurable key, this is used to authenticate with the proxy server
// This is checked against the EEPROM on boot and written if necessary
// The proxy server retreives the key from the EEPROM
byte key[] = { Personal KEY };

// Other required variables
byte data[257];
byte dataLength;
byte hexStage;
unsigned long lastInstruction = 0;
unsigned long lastRefresh = 0;
byte stage = 0;

// Declare client object
EthernetClient Client;

void setup()
{
  // This is here purely to add a bit of padding to the sketch to fix a compiling bug
  // http://arduino.cc/forum/index.php/topic,60649.0.html
  EEPROM.read(0);
  
  // Load presets
  Teleduino2560.loadPresets();
  
  // Set status LED pin
  Teleduino2560.setStatusLedPin(statusLedPin);

  Teleduino2560.setStatusLed(1); // Initialisation
  // Check the EEPROM header and check to see if the key is correct
  // This is to ensure the key is not cleared from the EEPROM
  if(EEPROM.read(0) != '#')
  {
    EEPROM.write(0, '#');
  }
  if(EEPROM.read(1) != 1)
  {
    EEPROM.write(1, 1);
  }
  if(EEPROM.read(2) != '#')
  {
    EEPROM.write(2, '#');
  }
  if(EEPROM.read(395) != '#')
  {
    EEPROM.write(395, '#');
  }
  for(byte i = 0; i < 16; i++)
  {
    if(EEPROM.read(396 + i) != key[i])
    {
      EEPROM.write(396 + i, key[i]);
    }
  }
  if(EEPROM.read(412) != '#')
  {
    EEPROM.write(412, '#');
  }

  // Start network and attempt to connect to proxy server
  Teleduino2560.setStatusLed(2); // Network configuration
  if(useDhcp)
  {
    if(!Ethernet.begin(mac))
    {
      Teleduino2560.setStatusLed(2, false, 10000);
      Teleduino2560.reset();
    }
  }
  else
  {
    Ethernet.begin(mac, deviceIp, dnsIp, gatewayIp, subnet);
  }
  delay(1000);

  Teleduino2560.setStatusLed(3); // Connect to server
  if((useDns && !Client.connect(serverName, serverPort)) || (!useDns && !Client.connect(serverIp, serverPort)))
  {
    Teleduino2560.setStatusLed(3, false, 10000);
    Teleduino2560.reset();
  }
  lastInstruction = millis();
}

void loop()
{
  if(Client.connected())
  {
    // What we need to do depends on which 'stage' we are at
    switch(stage)
    {
      case 0: // Wait for start byte
        if(Client.available())
        {
          char c = Client.read();
          if(c == '?')
          {
            stage++;
          }
        }
        break;
      case 1: // Reset variables
        dataLength = 0;
        hexStage = 0;
        stage++;
        break;
      case 2: // Instruction byte
        if(Client.available())
        {
          char c = Client.read();
          if(c == '?')
          {
            stage = 1;
            break;
          }
          else if(c == '\r' || c == '\n' || c == '.')
          {
            stage = 0;
            break;
          }
          if(!hexStage)
          {
            data[0] = Teleduino2560.hexDecode(c) * 16;
          }
          else
          {
            data[0] += Teleduino2560.hexDecode(c);
          }
          hexStage = !hexStage;
          if(!hexStage)
          {
            stage++;
          }
        }
        break;
      case 3: // Data length byte
        if(Client.available())
        {
          char c = Client.read();
          if(c == '?')
          {
            stage = 1;
            break;
          }
          else if(c == '\r' || c == '\n' || c == '.')
          {
            stage = 0;
            break;
          }
          if(!hexStage)
          {
            data[1] = Teleduino2560.hexDecode(c) * 16;
          }
          else
          {
            data[1] += Teleduino2560.hexDecode(c);
          }
          hexStage = !hexStage;
          if(!hexStage)
          {
            stage++;
          }
        }
        break;
      case 4: // Data
        if(Client.available())
        {
          char c = Client.read();
          if(c == '?')
          {
            stage = 1;
            break;
          }
          else if(c == '\r' || c == '\n' || c == '.')
          {
            if(dataLength == data[1])
            {
              stage++;
              break;
            }
            else
            {
              stage = 0;
              break;
            }
          }
          if(!hexStage)
          {
            data[2 + dataLength] = Teleduino2560.hexDecode(c) * 16;
          }
          else
          {
            data[2 + dataLength] += Teleduino2560.hexDecode(c);
          }
          hexStage = !hexStage;
          if(!hexStage)
          {
            dataLength++;
          }
        }
        break;
      case 5: // Execute instruction and return result
        Teleduino2560.instruction(data);
        Client.write('!');
        for(int i = 0; i < data[1] + 2; i++)
        {
          Client.write(Teleduino2560.hexEncode(data[i] / 16));
          Client.write(Teleduino2560.hexEncode(data[i] % 16));
        }
        Client.write('\n');
        lastInstruction = millis();
        stage = 0;
        break;
    }
  }
  else
  {
    Teleduino2560.setStatusLed(10);
    Teleduino2560.reset();
  }

  // Has the instruction timeout been reached?
  if(millis() - lastInstruction > 30000)
  {
    Client.flush();
    Client.stop();
    Teleduino2560.setStatusLed(9);
    Teleduino2560.reset();
  }

  // Process refreshes every 50ms
  if(millis() - lastRefresh >= 50)
  {
    Teleduino2560.pinTimers();
    Teleduino2560.shiftRegisterTimers();
    Teleduino2560.shiftRegisters();
    lastRefresh = millis();
  }

  // Check to see if reset has been requested
  Teleduino2560.checkReset();
}

I tried again this morning before work and got it to connect to the router using the example DHCP sketch. I quickly uploaded the Teleduino sketch and got Teleduino to work also (ping, set digital line, turned on an LED, etc). After about 5 minutes the service stopped working.

At this point I went ahead and uploaded the example DHCP sketch and again the serial monitor said Failed to connect.

Could this be a sign of a bad Mega or Ethernet Shield?

If you expect help on this forum, I recommend using the standard ethernet library.

Do you have any other SPI devices on the Arduino, like maybe a SD card in the shield's slot? That will cause DHCP to fail.

Tim,

I was under the impression that using #include <Ethernet.h> WAS the standard Ethernet library. Is that not the case? I have to plead ignorance unfortunately. I'm a proficient LabVIEW "programmer" but this Arduino code is not in my bag of tricks!

When I uploaded and tried the DhcpAddressPrinter I was having the same failed connection to the DHCP server...I'm also assuming that was using the standard Ethernet library.

There are no other SPI devices on the Arduino...no SD card in the slot.

I saw the Teleduino.h include and presumed it was a separate library.

If the DhcpAddressPrinter sketch doesn't work, you have a problem. I recommend testing the SPI bus and the SPI end of the w5100. Try this sketch. Does it display 192.168.2.2 on the serial monitor? If it shows anything else, like 0.0.0.0, then you have a SPI problem, and you should check that the shield is inserted correctly and fully into the Arduino.

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

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,2,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() {
}

Thanks Tim, I'll try out that code and report back my results.

Tim,

I uploaded the Sketch and the monitor showed:

Starting w5100
192.168.2.2

I went ahead and removed this section after I tested your code:

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

And the serial monitor showed the same information.

So...what does this indicate? An issue with my router perhaps?

So the only other thing I have going on with my home network is a Linksys WRT54G2 router (setup as a Gateway). This router was set up via ethernet cable from the Actiontec to ethernet port 1 (not "internet" port) of the WRT54G2. I did this because like the Arduino, the xBox absolutely would not connect to the Actiontec router via WiFi. So, after I hooked up the WRT54G2 router, the xBox immediately connected to it over WiFi and thus the internet...oddly though the xBox shows up in the Actiontec as an "ethernet" connection and not a Wifi connection.

Regardless, I tried plugging the ArduinoEthernet shield into the WRT54G2 router and the same thing is happening...Failed to configure Ethernet using DHCP.

Well, I've been at this for over 6 hours now and nothing has worked.

If anyone has any ideas, let me know.

I'm not sure how you have all these devices connected. Have you tried connecting the ethernet shield to the WRT54g without the Actiontec router connected to it? The WRT54g probably has a dhcp server. The Actiontec probably does too. That may cause a problem if they are on the same subnet.

It never occurred to me to try the WRT54G2 by itself.

I just unhooked it from the Actiontec, enabled the DHCP server on the WRT54G2 and tried the DhcpAddressPrinter again and "Failed to configure Ethernet using DHCP" came up again in the serial monitor.

My original configuration has the WRT54G2 connected Ethernet to Ethernet with the Actiontec. The WRT54G2 is setup in Gateway mode with a static IP address. DHCP is disabled on the WRT54G2 and anything connected wirelessly to it gets its IP from the DHCP server on the Actiontec. I had to do this due to my xBox not connecting to the Actiontec for whatever reason.

Either way I hook up the Arduino, WRT54G2 or the Actiontec, DHCP fails.

I've tried three different cables, two different routers and every configuration I can think of involving DHCP and Static IP.

I'm beginning to think the Ethernet Shield is bad.

And Tim, thanks for the help so far. This is driving me insane.

DHCP is disabled on the WRT54G2 and anything connected wirelessly to it gets its IP from the DHCP server on the Actiontec

Disconnect the Actiontec from the WRT54G2 and enable the DHCP server on the WRT54G2. Try it again.

You should connect the Actiontec to the WRT54 with the internet port of the WRT54 connected to the Actiontec. Enable the DHCP client on the internet port of the WRT54G2.

Tim,

The way I have the routers connected is secondary to my problem, I think.

Every other device in my network from Andoid phones to an iPad all get IP addresses and connect over WiFi and my Desktop connects via ethernet.

The Arduino board is the only one that doesn't work. I'm thinking it's bad. It's one of those third party boards from ebay (US seller kbellenterprises) with the HanRun ethernet jack. I don't know if anyone has had these issues with them, but I certainly am.

Well....I may have found the problem.

Red lines indicate solder bridging on the WizNET chip pins....

Mine:

Example Shield from internet with no solder bridging:

Others as well:


An update for posterity's sake:

I received a new ethernet board from the seller only to find that the SAME exact pins were solder bridged.

I plugged it into my MEGA, uploaded the DHCP example sketch and it connected immediately. I uploaded the Teleduino DHCP sketch and that also connected immediately and has been running for about 18 hours with no issues.

I have no explanation for this other than the bridged pins must be OK to be bridge and that my card must have had a separate issue.

Or...aliens.