EthernetShield Issues (no ip address, random addresses, etc.)

I just got an Ethernet Shield and an UNO. Everything (seems) to be working ok, but here is the issue I'm having.

If I use Ethernet.Begin(mac) - It hangs.

If I skip that and do Ethernet.Begin(mac, ip);

then call localIP, my localIP is always 0.0.0.0

I read on some forums that this is because the sd card slot is "seeing" the data. (I do not have an ad card in there at all).

So if I add this code (before calling Ethernet.begin):

pinMode(4, OUTPUT);
digitalWrite(4, HIGH);
delay(100);

Then call Ethernet.Begin(mac, ip), then check localIP... I do have an IP but it is seemingly random and not the one I was sticking in there and not one from my dhcp server (I can literally keep resetting my board and i'll keep getting new random ip addresses.

Any ideas? Also there was no mac address sticker on the board, I made one up.

Here is the full code listing:

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = {10,0,1,210};

void setup()
{
  pinMode(4, OUTPUT);
  digitalWrite(4, HIGH);
  delay(100);
 
  Serial.begin(9600);
 
  if (Ethernet.begin(mac) == 0)
  {
    Serial.println("DHCP failed.");
    Ethernet.begin(mac, ip);
  }
  
  Serial.println(Ethernet.localIP());
}

void loop()
{
}

Thanks for any help you can offer.

Perhaps you have a wrong version of the Ethernet shield.
If they both are version 'R3' it should work.

I still see some very old Ethernet shields on Ebay, perhaps you can make a photo of your shield ? or a link to where you bought it ?

Do you have enough power ?
When you for example use a laptop and a cheap cable, the Ethernet shield might not have enough power.

Is your ethernet cable okay ? Did you test it ?

Peter_n:
Perhaps you have a wrong version of the Ethernet shield.
If they both are version 'R3' it should work.

I still see some very old Ethernet shields on Ebay, perhaps you can make a photo of your shield ? or a link to where you bought it ?

Do you have enough power ?
When you for example use a laptop and a cheap cable, the Ethernet shield might not have enough power.

Is your ethernet cable okay ? Did you test it ?

I bought both from Radio shack the other day. I'm powering the arduino from the USB on my desktop. I took the ethernet cable off of another computer in my house (that has no issues with the cable).

Any other ideas?

I figured it out!!

Mine is new W5200. I needed to get the latest .cpp and .h files here:

Then (I'm on a Mac) i had to go to the actual Arduino application (in my applications folder) right click->show package contents.

Then overwrite the files in libraries/ethernet/utility

-Carmine