I just got my Ethernet shield and am trying to get something to work. I am entering the shield's MAC address into the script. Not sure which IP address to enter. I tried my Router's IP (198.1.168.1), various addresses within the supported range (198.168.100 - 149) and even the external IP from the ISP. All I ever get on the monitor is "connecting ...", "connection failed" and "disconnecting."
In the forum it is generally needed for you to post the code that does not work for you to see if it has issues. If you have a w5100 based ethernet shield you could try the below simple client code. The "my Router's IP (198.1.168.1)" is most probably incorrect (198.168.1.1 is typical). Once you load your code into the arduino, you can log into your router to see if the arduino is recgnized by the router.
//zoomkat 11-13-10
//simple ethernet client test code
//for use with IDE 0021 and W5100 ethernet shield
//modify the arduino lan ip address as needed
//open serial monitor to see what the arduino receives
//push the shield reset button to run client again
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 102 }; // Arduino IP address
byte server[] = { 208, 104, 2, 86 }; // zoomkat's web site
Client client(server, 80);
void setup()
{
Ethernet.begin(mac, ip);
Serial.begin(9600);
Serial.println("starting simple arduino client test");
Serial.println();
delay(1000);
Serial.println("connecting...");
if (client.connect()) {
Serial.println("connected");
client.println("GET /~shb/arduino.txt HTTP/1.0");
client.println();
} else {
Serial.println("connection failed");
}
}
void loop()
{
if (client.available()) {
char c = client.read();
Serial.print(c);
}
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
Serial.println("==================================");
Serial.println("");
client.stop();
for(;;);
}
}
I still get a connection failed message. I'm not suere where to look for an Arduino entry in my router info. The DHCP active IP table doesn't show the Arduino's MAC
Your arduino IP address has to be different from your router IP address. Just try the code I posted unchanged and see if it works. What brand of router do you have?