Go Down

Topic: ethernet shield (Read 3 times) previous topic - next topic

kuxi

hello,

i initialize my ethernet with:
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x2B, 0xC4 };
byte ip[] = { --- my ip --- };
byte gateway[] = { --- my router ip --- };
Server server(80);
void setup()
{
  Ethernet.begin(mac, ip, gateway);
  delay(1000);
  server.begin();

- but i can not ping the shield, it seems that the shield gets no ip and mac address
- dig. pins 10,11,13 gets high after uploading the scetch, is this ok?

can somebody help me......

CowJam

As far as I'm aware the ethernet shield has no built-in ping function.  If you want it to reply to a ping you have to programme it to.

The example sketch that grabs a google page is probably a good place to start to make sure it's working.  It grabs a web page and outputs it to the serial port so you can see it (well, see the raw html) in the serial monitor.

kuxi

the webclient example is also not working.

webclient: dig. pins 10 and 11 are always high
simple webserver: dig. pins 10,11 and 13 are always high

is this ok?

PaulS

Pin 10 is the chip select pin that selects the ethernet shield as the SPI device to talk to. You're trying to talk to the ethernet shield, aren't you? So, yes, pin 10 should be HIGH.

The status of pins 11, 12, and 13 depend on what the shield is doing at any given time.

kuxi

ok.

anyway, it doesn't work, if i try the webclient example, the shield can't connect to the server, it doesn't matter if there is a network cable pluged in, the serial monitor returns the same... (connection failed...)

i think "client.connect()" should return "1" or "0", but when i insert "println(client.connect());" it returns nothing...

can anybody help me?

PaulS

Quote
i think "client.connect()" should return "1" or "0"

client.connect() does return either a 0 or a 1.

Quote
but when i insert "println(client.connect());" it returns nothing...

Insert it where?

kuxi

in my code:

Code: [Select]

.
.
Serial.begin(9600);
  // give the Ethernet shield a second to initialize:
  delay(1000);
  Serial.println("connecting...");

  Serial.println(client.connect());

  // if you get a connection, report back via serial:
  if (client.connect()) {
.
.

zoomkat

If you have the w5100 shield, try the below to see if it works.

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.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(;;);
  }
}

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

marklar

Just a FYI.  My Ethernet shield (with SD) responds to ping expected.

PaulS

Quote
My Ethernet shield (with SD) responds to ping expected.

When running what code?

draythomp

I have three of the 'official' arduino ethernet cards running and all of them respond to pings.  I'm using the example code modified for my project.  So, the arduino ethernet cards do work with a ping.
Trying to keep my house under control http://www.desert-home.com/

kuxi

i have the official w5100 shield and i test it with the example codes (webserver, webclient).

- i can't ping it
- when i insert the line Serial.println(client.connect()) before the "if" query in the webclient code, it return a space, i don't know where the space comes from, because normaly it should return "1" or "0"

kuxi

my failure: client.connect() returns "0"

but i don't know realy why??????

this code in Client.cpp returns the 0:
Code: [Select]

while (status() != SnSR::ESTABLISHED) {
    delay(1);
    if (status() == SnSR::CLOSED) {
      _sock = MAX_SOCK_NUM;
      return 0;
    }
  }


can anybody help me????

kuxi

-the rx led is blinking
-the tx led does nothing, only if i change some things for example the ip of my laptop
-i think the tx should do something when i start the webclient example, but nothing....  :(

what do you think, is this a network or an ethernet shield problem???

PhilipT

Zoomkat
Thanks for that test listing

I'm just having a first dip into networking.

Ran your code having put in my Mac and IP and it conected quickly and printed your response...

Odd thing is, if I push reset to run again, it won't connect a second time unless I change my IP to another number  192.168.0. XX
then, it connects but only once...
:~

Go Up