This will answer part of your question. Try this test sketch. If the serial monitor shows 192.168.2.2, then the SPI end is working. If it shows anything else, like 0.0.0.0, then it isn’t working.
This will explain the SPI bus. It is the protocol that the ethernet shield uses.
Try this test sketch. It checks the RJ45 end of the w5100. If your ethernet shield is connected to a router, it should show an IP address if all is ok. If it stalls for a couple minutes and displays failed, then it is not working.
Then you seem to have a problem on the ethernet end of the w5100. Are the LEDs on the front of the RJ45 receptacle lit? Are the LEDs on the router for that port lit?
Then you have a problem. If the Arduino is 192.168.1.181, then why is the router (192.168.1.1) getting involved in this ping? What is the IP of the PC? Is it connected to an ethernet port on the router? Or is it wireless?
edit: If the Arduino and the PC are on the same localnet, this should be the result. It should be "Request timed out", not "Destination host unreachable". I pinged 192.168.1.250, which is an IP that no device is using on my localnet. My PC is 192.168.1.254.
C:\Documents and Settings\user>ping 192.168.1.250
Pinging 192.168.1.250 with 32 bytes of data:
Request timed out.
Ping statistics for 192.168.1.250:
Packets: Sent = 1, Received = 0, Lost = 1 (100% loss),
Control-C
^C
C:\Documents and Settings\user>
Here is an example of a ping to a non-existent IP on a different localnet than the PC. Note it is "Destination host unreachable". Also note my router (192.168.1.1) got involved in this ping.
C:\Documents and Settings\user>ping 192.168.2.3
Pinging 192.168.2.3 with 32 bytes of data:
Reply from 192.168.1.1: Destination host unreachable.
Reply from 192.168.1.1: Destination host unreachable.
Ping statistics for 192.168.2.3:
Packets: Sent = 2, Received = 2, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
Control-C
^C
C:\Documents and Settings\user>
Then what is the IP of the router? That may be your problem. It is normally 192.168.1.1. Look on your PC for its gateway. Use ipconfig from a command prompt to get that.
Simple client code you can try unmodified to see if you can get returned data from the server.
//zoomkat 3-1-13
//simple client checkip test
//for use with IDE 1.0.1 or later
//with DNS, DHCP, and Host
//open serial monitor and send an e to test
//for use with W5100 based ethernet shields
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
char serverName[] = "checkip.dyndns.com"; // test web page server
EthernetClient client;
//////////////////////
void setup(){
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
while(true);
}
Serial.begin(9600);
Serial.println("Better client ip test 3/1/13"); // so I can keep track of what is loaded
Serial.println("Send an e in serial monitor to test"); // what to do to test
}
void loop(){
// check for serial input
if (Serial.available() > 0) //if something in serial buffer
{
byte inChar; // sets inChar as a byte
inChar = Serial.read(); //gets byte from buffer
if(inChar == 'e') // checks to see byte is an e
{
sendGET(); // call sendGET function below when byte is an e
}
}
}
//////////////////////////
void sendGET() //client function to send/receive GET request data.
{
if (client.connect(serverName, 80)) { //starts client connection, checks for connection
Serial.println("connected");
client.println("GET / HTTP/1.0"); //download text
client.println("Host: checkip.dyndns.com");
client.println(); //end of get request
}
else {
Serial.println("connection failed"); //error message if no client connect
Serial.println();
}
while(client.connected() && !client.available()) delay(1); //waits for data
while (client.connected() || client.available()) { //connected or data available
char c = client.read(); //gets byte from ethernet buffer
Serial.print(c); //prints byte to serial monitor
}
Serial.println();
Serial.println("disconnecting.");
Serial.println("==================");
Serial.println();
client.stop(); //stop client
}