Pages: 1 [2] 3 4 ... 6   Go Down
Author Topic: NEWBIE needs Ethernet Help!  (Read 6818 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Tesla Member
***
Karma: 148
Posts: 9753
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
It also give it no MAC address.

If you do random stuff instead of trying the provided code that works for me, the expectation and most likely (and observed) result is failure.
Logged

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

Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The routines at this website (sheepdog) appears to use a library I don't have (Ethershield), so I can't compile the code.  WHY IS THIS SO HARD??  Surely there is something simple, stupidly wrong with what I'm doing.  BTW, I now get a "dynamic" ip address of 192.168.0.102 for Arduino, so I guess that's progress...

Have still been unable to make connection using any example software or suggested code.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The routine at this website (SheepDog) appears to use a library I don't have, Ethershield.  So I can't compile the code. 

BTW, the arp -a now reports Arduno at 192.168.0.102 and type "dynamic" so I guess this is progress...but still not listed as an attached device by the router.  All lights flashing happily.  Still have not achieved connection with any software routine, example, etc.  '

WHY IS THIS SEEMING SO HARD?? Surely there is something simple, stupidly wrong with what I'm doing. 
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

To zoomkat-
I did exactly as you suggested, but was unable to achieve connection.  So I don't know what's wrong, but it is not "doing random things rather than using provided code".  I do surely appreciate your help and suggestions, btw.  I am just getting a bit frustrated.

The arp -a does now also give the Arduino a MAC address de-ad-be-ef-fe-ed.
Logged

0
Offline Offline
Tesla Member
***
Karma: 148
Posts: 9753
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Below is some simple server code you can try on your lan using your pc connected to the router. You need to change the 1 to a 0 in the ip address and url like you have previuosly done to match your router.

Code:
// for W5100 ethernet shield
// the IP address will be dependent on your local network/router
// port 80 is default for HTTP, but can be changed as needed
// use IP address like http://192.168.1.102:84/ in your brouser

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

int x=0;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 102 };
Server server(84);

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

void loop()
{
  // listen for incoming clients
  Client client = server.available();
  if (client) {
     while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // see if HTTP request has ended with blank line
        if (c == '\n') {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
         
          //meta-refresh page every 2 seconds
          x=x+1;
          client.print("<HEAD>");
          client.print("<meta http-equiv=\"refresh\" content=\"2\">");
          client.print("<TITLE />Zoomkat's meta-refresh test</title>");
          client.print("</head>");
          client.print("page refresh number ");
          client.println(x);
          client.println("<br />");
          client.println("<br />");
                             
          // 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;
           }
        }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
  }
}

Logged

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

Valencia, Spain
Online Online
Faraday Member
**
Karma: 152
Posts: 5759
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Surely there is something simple, stupidly wrong with what I'm doing.

If you can't look at the provided code and see the words "mac" and "ip" on the third/fourth lines (after the comment) then there's not much hope...

PS: Arduino shields don't do DHCP.

« Last Edit: September 18, 2011, 04:45:24 am by fungus » Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Sussex UK / CT USA
Offline Offline
Edison Member
*
Karma: 0
Posts: 1028
Forums forever
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The library you need for the example at the Sheepdog Software is part of the standard Arduino environment... if you installed it correctly.

Bit harsh, Fungus... we weren't born knowing about "MAC", "IP", "DCHP", were we?

These things explained at SheepdogSoftware page.
Logged

0
Offline Offline
Tesla Member
***
Karma: 148
Posts: 9753
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The library you need for the example at the Sheepdog Software is part of the standard Arduino environment... if you installed it correctly.

The "//initialize enc28j60" in the code at the Sheepdog Software site indicates that it will probably not be compatable with the wiznet chip the OP has.
Logged

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

Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Zoomkat-
Your server code works just fine if I use Firefox as the web browser, but not IE.  Any idea why?
I now see the Arduino listed by the arp -a command as a "dynamic" device, correct ip address and MAC.  I've no idea why things are now working but am grateful for at least some progress!

Thanks for the help!  I appreciate your patience.  Will next try internet connection and see what happens...
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

fungus-
I do know what a MAC and ip address are, and have changed them accordingly in each code I've used.
This does not appear to be the problem.

Us newbies do appreciate the helpful tone most people use on this forum.  We are here to learn from you, after all...
Logged

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

If the code works on Firefox and not IE, check your IE security settings. One of them enables/disables Meta Refresh. Could that be the problem?

Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sounds like an excellent suggestion, but META-refresh is enabled. 

There are a bunch of other options in the Tools menu, too many to try randomly.
Logged

London, UK
Offline Offline
Full Member
***
Karma: 4
Posts: 190
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Surely there is something simple, stupidly wrong with what I'm doing.

PS: Arduino shields don't do DHCP.


dude they do as long as he has the W5100 module (standard Ethernet shield or Arduino Ethernet)
the library i am using is

http://gkaindl.com/software/arduino-ethernet
Logged

0
Offline Offline
Tesla Member
***
Karma: 148
Posts: 9753
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Your server code works just fine if I use Firefox as the web browser, but not IE.  Any idea why?

My laptop has IE7 and the meta refresh works ok. Below is another server code to try.

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

0
Offline Offline
Tesla Member
***
Karma: 148
Posts: 9753
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Meta refresh in ie8 is turned on/off in the custom section of internet security per the below link.

http://helpdeskgeek.com/how-to/disable-meta-refresh-ie-8/
Logged

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

Pages: 1 [2] 3 4 ... 6   Go Up
Jump to: