Go Down

Topic: Implementing the WebClient Sketch from the Arduino-0022 Examples (Read 2280 times) previous topic - next topic


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 (, 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."

Any ideas what I'm doing wrong?


Any ideas what I'm doing wrong?

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 (" is most probably incorrect ( 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.

Code: [Select]

//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.println("starting simple arduino client test");



  if (client.connect()) {
    client.println("GET /~shb/arduino.txt HTTP/1.0");
  } else {
    Serial.println("connection failed");

void loop()
  if (client.available()) {
    char c = client.read();

  if (!client.connected()) {

Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.


Thank you for your advice on the use of the forum. As you can see I'm new at it.

you are right about the router IP address. I made a typo in the post, not the sketch. It is

I used your sketch and altered only the following:

byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x50, 0xDD };
byte ip[] = { 192, 168, 1, 1 }; // Arduino IP address

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?
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.


Wow. That worked.

I use a LinkSys WRT54G router. Can't find any reference to my Arduino in it


AJB2K3 is often grabbed by the modem router.

if this is an ip issue, download and install wireshark and look at the output.
Sorry for the noobish post but my knowledge is 10 years out of date!


Go Up