[SOLVED] Uno + Ethernet Shield - can't get it to work :(

Hi all,

I bought yesterday Uno + Ethernet Shield. Uno is working (i blinked a LED). Here is the pic of Eth shield:

PC ip: 192.168.1.201 mask: 255.255.255.0 gateway: 192.168.1.1

And i tried to do this: https://www.youtube.com/watch?v=nYzEbEOMGuo

UNO IP: 192.168.1.222

I wanna just try something to see if the shield is working. And i cant get it to work. When i try to ping it in cmd i get this message: "Destination host unreachable".

Can someone give me an advice what to do?

Thank you.

EDIT: I solved it. Look at #22

This short sketch tests the SPI bus and the SPI side of the w5100. If the serial monitor shows 192.168.0.2, then that part is working. If it shows anything else, you have a problem there.

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,0,2);

void setup() {
  Serial.begin(9600);

  // disable SD card if one in the slot
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);

  Serial.println("Starting w5100");
  Ethernet.begin(mac,ip);

  Serial.println(Ethernet.localIP());
}

void loop() {
}

Hi all, How Can I get the Adress ip of my arduiwo?

Thanks in advance. Regards

Imanesirin: Hi all, How Can I get the Adress ip of my arduiwo?

Thanks in advance. Regards

If you mean after using dhcp to get an IP, then this will do it.

  Serial.println(Ethernet.localIP());

Thanks for yr reply, in this line IPAddress ip(192,168,1,5);

I should write in thid line the AdresIP of pc or arduino? Thanks in advance.

and When I type this adress in the web (192,168,1,5); its askes me to login with password,

how Can I get it?

@Imanesirin: You should start your own thread. Hijacking another user's thread is not polite.

Sorry ,but I don't understand y,what do you mean by thread?.

Click this link, then click on the button that says "NEW TOPIC". http://forum.arduino.cc/index.php?board=11.0

SurferTim: This short sketch tests the SPI bus and the SPI side of the w5100. If the serial monitor shows 192.168.0.2, then that part is working. If it shows anything else, you have a problem there.

...

Thank you for your relplay. I got this, looks like it works.

But why is the web server example not working? That guy in video did it in 2 min, and i lost like 1h and i could not do that.

After the test I have changed 192.168.0.2 to 192.168.1.222 (cause my PC ip is 192.168.1.201) and i tried to ping it and i could not (same arror as i described in my first post) :(

The SPI bus is working ok. Now try a dhcp IP request with this code. Does it get an IP or does it fail? What IP does it get? Can you ping that IP?

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

void setup() {
  Serial.begin(9600);

  // disable SD card if one in the slot
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);

  Serial.print("Starting w5100...");
  if(!Ethernet.begin(mac)) Serial.println("failed");
  else Serial.println(Ethernet.localIP());
}

void loop() {
}

Looks like it fails

Then it appears you have a problem on the ethernet side of the w5100 or the connection to the router. You are connected to a router, right? Or are you connected to the ethernet port of the PC and the PC connects to the internet with a wireless connection?

This is my configuration:

This arduino cable is my spare Eth cable. I use it with different devices when i do something. Now is arduino connected to it. Connection should not be a problem.

If your PC gets an IP using dhcp, then you have a problem on the ethernet side of the w5100 or the CAT5 cable connecting the w5100 to the router is bad.

Looks like cable is ok. Tried to connect to it my plc and i can ping his ip. Is there a way to check what i broken, cause arduino and eth shield are new (bought them yesterday)?

If you know the CAT5 cable is good, then the w5100 has a problem on the ethernet side of the IC. You have tried the tests I use to check the w5100. The SPI bus side is ok, but the ethernet side fails.

I recommend contacting your supplier and tell them what you found. Sending them a link to this thread might help your case in getting a replacement.

Thank you for your help. I will respond when i get some answers

Simple client code you can try to see if you get a response from the server.

//zoomkat 11-04-13
//simple client test
//for use with IDE 1.0.1
//with DNS, DHCP, and Host
//open serial monitor and send an e to test client GET
//for use with W5100 based ethernet shields
//remove SD card if inserted
//data from myIP server captured in readString 

#include <SPI.h>
#include <Ethernet.h>
String readString;

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address

char serverName[] = "checkip.dyndns.com"; // myIP server 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("client readString test 11/04/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
  Serial.println();
}

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.1"); //download text
    client.println("Host: checkip.dyndns.com");
    client.println("Connection: close");  //close 1.1 persistent connection  
    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
    readString += c; //places captured byte in readString
  }

  //Serial.println();
  client.stop(); //stop client
  Serial.println("client disconnected.");
  Serial.println("Data from server captured in readString:");
  Serial.println();
  Serial.print(readString); //prints readString to serial monitor 
  Serial.println();  
  Serial.println();
  Serial.println("End of readString");
  Serial.println("==================");
  Serial.println();
  readString=""; //clear readString variable

}

@zoomkat: It won't work. See replies #10 and 11.