Go Down

Topic: NEWBIE needs Ethernet Help! (Read 7295 times) previous topic - next topic

zoomkat

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.
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

ipsolutions

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.

ipsolutions

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. 

ipsolutions

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.

zoomkat

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: [Select]

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

Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

fungus

#20
Sep 18, 2011, 11:36 am Last Edit: Sep 18, 2011, 11:45 am by fungus Reason: 1

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.

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

tkbyd

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.

zoomkat

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.
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

ipsolutions

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

ipsolutions

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

SurferTim

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?


ipsolutions

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.

mrjonny2



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

zoomkat

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: [Select]

//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="";

        }
      }
    }
  }
}

Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

zoomkat

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/
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

Go Up