Pages: [1]   Go Down
Author Topic: ethernet shield  (Read 2737 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 29
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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......
Logged

Wigan, UK
Offline Offline
God Member
*****
Karma: 19
Posts: 814
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 29
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 29
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 29
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

in my code:

Code:
.
.
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()) {
.
.
Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9470
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
//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(;;);
  }
}
 
Logged

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

Florida
Offline Offline
Sr. Member
****
Karma: 4
Posts: 431
hookedup!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
My Ethernet shield (with SD) responds to ping expected.
When running what code?
Logged

New River, Arizona
Offline Offline
God Member
*****
Karma: 19
Posts: 928
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Trying to keep my house under control http://www.desert-home.com/

0
Offline Offline
Newbie
*
Karma: 0
Posts: 29
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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"
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 29
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

this code in Client.cpp returns the 0:
Code:
while (status() != SnSR::ESTABLISHED) {
    delay(1);
    if (status() == SnSR::CLOSED) {
      _sock = MAX_SOCK_NUM;
      return 0;
    }
  }

can anybody help me????
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 29
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

-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....  smiley-sad

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
 smiley-confuse
Logged

Pages: [1]   Go Up
Jump to: