Firstly, here is the ethernet shield I am using. Supposedly it is fully compatible with the Uno
The instant that I insert an ethernet cable into the RJ45 socket the link, 100M, and fulld lights illuminate. This certainly makes it seem as though the board is not dead. I also have an LED in digital pin 13 and ground which supposedly is the ethernet chip's clock.
19 times out of 20 when I issue a Ethernet.begin(mac) command, code execution hangs for 90 seconds and an LED inserted between digital pin 13 and GND stays solidly lit. For whatever reason, some random bits of new code will work just fine, instantly establish a DHCP connection and send and receive data. Below is some troubleshooting code that ran perfectly the first time I tried it and has failed every time since then:
#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[] = { 0x11, 0xBB, 0xBB, 0xCC, 0xDE, 0x05 };
char serverName[] = "www.google.com";
// 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);
delay(500);
// start the Ethernet connection:
Serial.println("Attempting 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);
}
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect(serverName, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /search?q=arduino HTTP/1.0");
client.println();
}
else {
// kf you didn't get a connection to the server:
Serial.println("connection failed");
}
}
void loop()
{
// if there are incoming bytes available
// from the server, read them and print them:
if (client.available()) {
char c = client.read();
Serial.print(c);
}
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
// do nothing forevermore:
while(true);
}
}
Can anyone suggest anything to help stabilize things for me? I know the shield isnt' dead since I've had it send data but it is extraordinarily unreliable.