Pages: [1] 2 3   Go Down
Author Topic: arduino wiznet w5100 ethernet shield problem  (Read 5411 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys i'm new in this. I have a ardiuno duemilanove and an ethernet shield w5100.
I can't get it work with my ardiuno . I can't ping the device i try to many times .
Help me.


This is the code i'm using.
/*
  Web  Server
 
 A simple web server that shows the value of the analog input pins.
 using an Arduino Wiznet Ethernet shield.
 


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

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192,168,1, 177 };

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
Server server(80);

void setup()
{
  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
}

void loop()
{
  // listen for incoming clients
  Client client = server.available();
  if (client) {
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();

          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(analogRead(analogChannel));
            client.println("<br />");
          }
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
  }
}


* 503055090_o.jpg (82.27 KB, 600x600 - viewed 33 times.)
« Last Edit: October 08, 2011, 10:28:05 am by julianiii » Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5974
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What is the ip and subnet of the computer that you are using for the ping attempt?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

IP:192.168.1.184
Subnet mask: 255.255.255.0

I have both my pc and ardiuno in the same range

i also have enc28j60 ethernet shield and works perfect. Maybe is library problem with w5100. I use ardiuno 0022 software
« Last Edit: October 08, 2011, 11:09:21 am by julianiii » Logged

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

Simple server code. If the arduino is connected to a router, then it may need to be specified as the gateway.

Code:
//zoomkat 12-18-10
//routerbot code
//for use with IDE 0021
//open serial monitor to see what the arduino receives
//use the \ slash to escape the " in the html
//address will look like http://192.168.1.102:84/ when submited
//for use with W5100 based ethernet shields

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 102 }; // ip in lan
byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
Server server(84); //server port

String readString;

//////////////////////

void setup(){

  pinMode(4, OUTPUT); //pin selected to control
  //start Ethernet
  Ethernet.begin(mac, ip, gateway, subnet);
  server.begin();

  //enable serial data print
  Serial.begin(9600);
  Serial.println("servertest1"); // so I can keep track of what is loaded
}

void loop(){
  // Create a client connection
  Client client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

        //read char by char HTTP request
        if (readString.length() < 100) {

          //store characters to string
          readString += c;
          //Serial.print(c);
        }

        //if HTTP request has ended
        if (c == '\n') {

          ///////////////
          Serial.println(readString);

          //now output HTML data header

          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();

          client.println("<HTML>");
          client.println("<HEAD>");
          client.println("<TITLE>Arduino GET test page</TITLE>");
          client.println("</HEAD>");
          client.println("<BODY>");

          client.println("<H1>HTML form GET example</H1>");

          client.println("<FORM ACTION=\"http://192.168.1.102:84\" method=get >");

          client.println("Pin 4 \"on\" or \"off\": <INPUT TYPE=TEXT NAME=\"LED\" VALUE=\"\" SIZE=\"25\" MAXLENGTH=\"50\"><BR>");

          client.println("<INPUT TYPE=SUBMIT NAME=\"submit\" VALUE=\"Change Pin 4!\">");

          client.println("</FORM>");

          client.println("<BR>");

          client.println("</BODY>");
          client.println("</HTML>");

          delay(1);
          //stopping client
          client.stop();

          /////////////////////
          if(readString.indexOf("on") >0)//checks for on
          {
            digitalWrite(4, HIGH);    // set pin 4 high
            Serial.println("Led On");
          }
          if(readString.indexOf("off") >0)//checks for off
          {
            digitalWrite(4, LOW);    // set pin 4 low
            Serial.println("Led Off");
          }
          //clearing string for next read
          readString="";

        }
      }
    }
  }
}

Logged

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

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I try it but without success. I cant get it ping.
??


* IMG_0372.JPG (272.09 KB, 1893x1629 - viewed 49 times.)
« Last Edit: October 08, 2011, 11:34:49 am by julianiii » Logged

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

You probably need to detail your lan setup. If you try code that is not changed to match your lan, it probably won't work.
Logged

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

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

what can i try else?? smiley-roll-sweat
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5974
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can try this. Compile and upload. Open the serial window and wait for "Tick Tick Tick".
Wait a few seconds, then try to ping 192.168.1.2
Code:
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x59, 0x66 };  
byte ip[] = { 192, 168, 1, 2 };    
byte gateway[] = { 192, 168, 1, 1 };
byte subnet[] = { 255, 255, 255, 0 };

void setup()
{
  Serial.begin(9600);
  Ethernet.begin(mac, ip, gateway, subnet);
  delay(1000);
}

void loop()
{
  Serial.println("Tick");
  delay(1000);
}

Then try to ping 192.168.1.1, just as a test. Does it respond?
« Last Edit: October 08, 2011, 12:08:08 pm by SurferTim » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Same problem.??


* 020.jpg (211.8 KB, 1680x1050 - viewed 126 times.)
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5974
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, tick is working, so it is not locking up. That is a good thing.

What is the router ip address for your localnet? Can you ping the router from the computer?
Is your router IP 192.168.1.157?
« Last Edit: October 08, 2011, 12:16:54 pm by SurferTim » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

im in a domain network
yes i can ping router
router ip : 192.168.1.157 / 192.168.1.134

« Last Edit: October 08, 2011, 12:18:54 pm by julianiii » Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5974
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Your subnet is 255.255.255.0 on that network?
Have you tried a cable change?
Are both the computer and Arduino connected to the same port on the router? Like a switch? Or different ports?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

yes my subnet is 255.255.255.0
yes i changed the cable and the pc, i even connected to the same switch. but is the same problem

i use the same configuration for enc28j60  ethernet shield and works fine
« Last Edit: October 08, 2011, 12:29:45 pm by julianiii » Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5974
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Let's see if the Arduino is actually talking to the shield. Compile and upload the following code. Open the serial window.
The first line of the serial responses should be the ip address you assigned to the shield.
Code:
#include <SPI.h>
#include <Ethernet.h>
#include <utility/w5100.h>

byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x59, 0x66 }; 
byte ip[] = { 192, 168, 1, 7 };   
byte gateway[] = { 192, 168, 1, 157 };
byte subnet[] = { 255, 255, 255, 0 };

byte ipBuf[4];
char outBuf[18];

void setup()
{
  Serial.begin(9600);
  Ethernet.begin(mac, ip, gateway, subnet);
  delay(1000);
  W5100.getIPAddress(ipBuf);
  sprintf(outBuf,"%u.%u.%u.%u\r\n",ipBuf[0],ipBuf[1],ipBuf[2],ipBuf[3]);
  Serial.write(outBuf);
}

void loop()
{
  Serial.println("Tick");
  delay(1000);
}
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No i dont get the ip from theserial responses


* 020.jpg (168.17 KB, 1677x1050 - viewed 104 times.)
Logged

Pages: [1] 2 3   Go Up
Jump to: