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.